Tuesday, December 21, 2010

Access Private Variables and Methods in Python

If your class is intended to be subclassed, and you have attributes that you do not want subclasses to use, consider naming them with double leading underscores and no trailing underscores. This invokes Python's name mangling algorithm, where the name of the class is mangled into the attribute name. This helps avoid attribute name collisions should subclasses inadvertently contain attributes with the same name.
Private variables and methods are just name mangling in Python. You can access a private variable by using _ClassName__privateVarName.
class Foo:
def __init__(self):
self.__privateVar = 12

def __privateMethod(self):
return 'Private method invoked'

def greetings(self):
return 'Hello World!'

>>> foo = Foo()
>>> foo.greetings() #public method
'Hello World' #output
>>> foo._Foo__privateVar #private variable
12 #output
>>> foo._Foo__privateMethod() #private method
'Private method invoked' #output

Thursday, December 16, 2010

Flex 4 Syntax Highlighting in Vim

There is syntax highlighting for Flex 3 and ActionScript 3 *. For Flex 4 syntax highlighting you have to make only a few changes to this mxml.vim file as follows:
1. Find the line:
syn keyword mxmlSpecialTagName  contained mx:Script mx:Style
and replace it with:
syn keyword mxmlSpecialTagName  contained mx:Script mx:Style fx:Script fx:Style
2. If you have found the above line go five line down and you will a sync with mx:Script tag. So you add these one too:
syn region Script start=+]*>+ keepend end=++me=s-1 contains=@mxmlScript,mxmlCssStyleComment,mxmlScriptTag,@htmlPreproc
syn region mxmlScriptTag contained start=++ contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent
Alternatively you can download the vim script file from vim.org

Tuesday, November 23, 2010

Inside Nokia N900

Complete details on the components inside the Nokia N900 can be viewed from the electronicproducts.com website.
You have the model number, vendor, build material type etc, which can help you in learning more about those electronic components in depth.

Sunday, November 21, 2010

Root Access In Nokia N900

The Maemo Operating System which comes with the Nokia N900 allows you to have super user (root) privilege without you having to jailbreak like most other devices.
1. In-order to get root access you need to install the package called
2. Open your App Manager -> Download -> System. Find it, you will. You must ensure that you have the extras repository in your Application Catalogue which will have the name maemo.org by default.
3. Install rootsh.
4. Open the Terminal using:
Ctrl + Shift + X
or by going to the installed apps & clicking the Terminal icon.
5. Type:
You'll get a response "user".
Now type:
sudo gainroot
Alternatively, you can type 'root' or 'sudo su -'
Now check with "whoami" and you'll get the response as "root".

Take & Share Screenshots from Nokia N900

Taking screenshot and sharing them online is really easy.
To take screenshot (print screen) you simply have to press:
Ctrl + Shift + P
To press that combination is easy, you just have to keep the index finger on the shift, middle finger on Ctrl and the right thumb on P (or which ever way you are comfortable with using the combination).
You can goto the photos from the application and see them there.
Add tags, choose share and choose the service you want (like flickr).

Sunday, November 14, 2010

Compiling GTK+ Programs in Ubuntu

There are easy to follow gtk+ 2.0 tutorials. I learn by referring to the official gnome gtk+ tutorials and from zetcode.com
When compiling most often many of us newbies have got the error: "No such file or directory" even if you have all the gnome-gtk-devel and other required packages. Also you don't need to set any environment variables to make it work.
gcc: pkg-config --cflags --libs  gtk+-2.0: No such file or directory
simple.c:1: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.
If that's the case then just see what command you have entered. Most probably you might have entered:
gcc -Wall -g simple.c -o simple 'pkg-config --cflags --libs  gtk+-2.0'
where simple.c is the filename. Note that the quote in which the pkg-config is written is ' character which is near to your Enter key. If so then that's the mistake. The character must be ` which is in the tilde (~) key, above the tab key.
So the correct way will be:
gcc -Wall -g simple.c -o simple `pkg-config --cflags --libs  gtk+-2.0`
The character ` is called 'backtick
If you are still confused with those little nasty quote characters, which makes newbie life miserable you can all together forget about this and use the one shown below:
gcc -Wall -g simple.c -o simple $(pkg-config --cflags --libs  gtk+-2.0)
It does the same thing, outputs the list of files, to be included and linked and likewise. To know more about that you can read the docs.

Wednesday, November 3, 2010

File Manager in Ubuntu Maverick Meerkat

If you are using the netbook remix edition of the Ubuntu 10.10 Maverick Meerkat, then by default you can see the 'Files & Folders' icon in the dock bar, which will display the files inside your home directory only. So if you need to mount other partitions, you can use bash if you are a power user. But if you want our good old simple file browser, then what you need to do is:
1. Open the trash.
2. Trash is opened in the file browser.
3. Now the 'File Browser' icon appears in the dock.
4. Right-click the 'File Browser' icon and choose 'Keep in Launcher'.

Sunday, October 31, 2010

Know the Version of Ubuntu

To know the version of Ubuntu (GNU/Linux) you are running, just enter
cat /etc/issue
in the bash terminal.

Sunday, October 24, 2010

Generate Star Pattern

The below code is in AS 3.0.
First from the components drag the TextArea component to the stage. Then give it an instance name txt. Then begin hacking.
var lines:int = 5;
var star:String = "*";
var space:String = " ";

var i:int;
var j:int;
var k:int;
var str:String="";

function init():void
/* Upper Triangle */
for( i=0; i< lines; i++ ) {
j = i;
str = "";
for( k=0; k<5-i; k++ ) {
str += space;
while( j != 0 ) {
str += star + space;
txt.text += str + "\n";

/* Lower Triangle */
for( i=lines; i!=0; i-- ) {
j = i;
str = "";
for( k=0; k<5-i; k++ ) {
str += space;
while( j != 0 ) {
str += star + space;
txt.text += str + "\n";

* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
The idea behind this
Its easier to think with lower triangle taken first. For the time being lets consider that we need only the lower triangle. i.e, say there will be 5 lines, and in the first line there will be 5 stars, in the second line there will be 4 stars and so on.
Think that if we simply put a for loop with the number of lines (5) and decrement it, in the first iteration we get 5, second iteration 4, (yeah, I know everyone knows that!), which is the number of stars we need to show per line. Now what we need is to actually display those number of stars.
The idea is concatenate those number of stars into a string and display them. Now what we get is a right angled triangle. That's because we need to concatenate the correct space along with the string. That's what the for loops in line number 16, and 30 does.
Now we have required triangle. You can easily make a recursive version if you would like.

Friday, October 22, 2010

Bitwise Shift Operator Performance

Bitwise shift operators ( shift left <<, and shift right >> ) can be used in multiplying and dividing if the divisor is a power of 2. Here I ran a test which shows that bitwise shift operators perform twice faster than the multiplication or division operators.

Shift Right ( >> )
When you need to divide a number by 2 or its power we can instead use shift operator. You read more about the theory behind it elsewhere, say wikipedia.
//shift right ( divide )
trace( 12 >> 1 ); //6
trace( 12 >> 2 ); //3
//shift left ( multiply )
trace( 12 << 1 ); //24
trace( 12 << 2 ); //48
Shifting right by one position is similar to divide by 2, and shifting right by two position is similar to divide by 4.
Similarly, is the case with shift left ( << ) where you will be multiplying the value instead.
// bit shift vs divide operator performance
var bigNum:int = 100000000; //8-zeros
var i:int=0;

function computeDiv():void
for( i=0; i<100000000; i++ ) {
bigNum = bigNum / 2;

function computeShift():void
for( i=0; i<100000000; i++ ) {
bigNum = bigNum >> 1; //shift right

var t0:Number = getTimer();
trace( t0 ); //22
var t1:Number = getTimer();
trace( t1 ); //4017
trace( "Time elapsed (Division): " + String( t1 - t0 ) ); //3995

var t2:Number = getTimer();
trace( t2 ); //4017
var t3:Number = getTimer();
trace( t3 ); //5689
trace( "Time elapsed (Shift): " + String( t3 - t2 ) ); //1672
This shows that the bit wise operators perform better than multiplication or division operators. This is tested using the debug version of the flash player. Using the normal version might show better results.

Monday, October 11, 2010

ActionScript 3 Performance Analysis

I was reading the post written in a blog (post1, post2) where the author compares various languages (Erlang, Python, Ruby, C, JavaScript, Lua, PHP, Common Lisp, Haskell), using a program which computes Pythagorean triplets. I just tried with ActionScript 3 and I'm not able to post any comments in that blog. So I'm writing it here.
import flash.utils.Timer;

var t0:int = getTimer();
trace( "result: " + pythag( 5000 ) );
var t1:int = getTimer();
trace( "Elapsed Time (s): " + String( ( t1 - t0 ) / 1000 ) );

function pythag( n:int ):int
var a:Number;
var b:int;
var c:int;
var i:int;

for( c=2; c<=5000; c++ ) {
for( b=1; b < c; b++ ) {
a = Math.sqrt( c*c - b*b );
if( Math.floor( a ) == a ) {
return i;
Time elapsed is 3.53 s. That's fast. Giovanni Intini (the author of that post) was running on a dual core MacBook Pro. I'm running this on a Pentium D dual core. So it must be a fair comparison. So here are the comparison from that site:
C: 0.40s
Lua: 3.44s
ActionScript 3: 3.53s
Erlang(smp): 3.95s
Erlang (non-smp): 5.66s
PHP5: 8.9s
Python(2.5.1): 11.2s
Ruby: 12.30s
JavaScript: -- (script stopped -taking too much time).

Tuesday, October 5, 2010

Recursion Using Anonymous Function in ActionScript 3

You must be familiar with recursion with normal functions, i.e a function calling itself. An anonymous function is a function without a name. So to use recursion in an anonymous function you call the arguments.callee() to refer to the anonymous function.
If its a normal function we can call that function using its name. Anonymous function don't have name, but you can refer the function using the callee method.

How to approach recursion?
The key idea to recursion is the terminating condition. First you need to figure out when the function should terminate. Then you think on how to generalize. Means first you look at when the factorial function say fact(n) should terminate, i.e, when n==1.

A normal function that computes factorial (I'm choosing factorial because its simple, and easy to understand) can be like:
function fact(n):int {
if(n==1) return 1;
else return n * fact(n-1);
In terms of anonymous function:
var fact:int = (function(n):int {
if(n==1) return 1;
else return n * arguments.callee(n-1);


Function Arguments in Depth

Function which takes infinite arguments
function infiniteArgs(...args):void {
trace( args );
infiniteArgs( 1, 2 );
infiniteArgs( 1, 2, 3, 4, 5 );
infiniteArgs( 1, 2, 3, 4, 5, 6, 7 );
infiniteArgs( 'a', 'b', 'c' );
Another method without all this hassle is to do like the below. I recommend this instead of the above method:
var inf:Function = function():void {
inf( 1, 2, 3, 4 );
inf( 'a', 'b' );
Arguments array
function foo( a:int, b:int, c:int ):void {
trace( arguments ); //displays the arguments passed
foo( 1, 2, 3 );
foo( 0, 10, 110 );
It will display the arguments passed into the function.
Now you can use arguments.length, arguments[0] etc.
function foo( a:int, b:int, c:int ):void {
trace( "args: " + arguments );
trace( "len: " + arguments.length );
trace( "arguments[2]: " + arguments[2] );
foo( 1, 2, 3 );
foo( 1, 10, 110 );
When using mutliple parameters the arguments are referred by the variable that you put after the 3 dots. i.e:
function foo(...myCoolArgs):void {
//instead of myCoolArgs if you gave arguments you'll get undefined error.
trace( "args: " + myCoolArgs );
trace( "len: " + myCoolArgs.length );
Passing arguments to another function
You have a function which received arguments. You need to send those arguments to another function as arguments itself instead of an array. For that you can use the 'apply' function.
//normal situation
function fooA(...myCoolArgs):void {
trace( "args: " + myCoolArgs );
trace( "len: " + myCoolArgs.length ); //you get 5
fooB( myCoolArgs );

function fooB(...args):void {
trace( "args: " + args );
trace( "len: " + args.length ); // you get 1 instead of 5

fooA( 0, 1, 2, 3, 4 );
Its passed as an argument array. So what you do is:
function fooA(...myCoolArgs):void {
trace( "args: " + myCoolArgs );
trace( "len: " + myCoolArgs.length ); //you get 5
fooB.apply( this, myCoolArgs ); //pass it like this

function fooB(...args):void {
trace( "args: " + args );
trace( "len: " + args.length ); // now you get 5

fooA( 0, 1, 2, 3, 4 );
More cooler version:
var fooA:Function = function():void {
trace( "args: " + arguments );
trace( "len: " + arguments.length );
fooB.apply( this, arguments );

var fooB:Function = function():void {
trace( "args: " + arguments );
trace( "len: " + arguments.length );

fooA( 0, 1, 2, 3, 4 );
fooA( 'a', 'b', 'c' );

Self invoking functions in ActionScript 3

Consider this normal example:
function greetings():void 
trace( "Hello World" );
This will display "Hello World".

The above example can be written in more elegant way (i.e., self invoking the function) as:
(function greetings():void {
trace( "Hello World" );
You get the same result. It's a function expression. Function expression syntax is of the form:
( f )();
Another example:
(function greetUser( name:String ):void {
trace( "Hello " + name );
You pass an argument during self invocation.

However one important thing you must consider is the scope.
(function greetUser( name:String ):void {
trace( "Hello " + name );

greetUser( "Foo" ); //will result in error
So note that.

Sunday, October 3, 2010

Install Consolas font in Windows without Visual Studio

Consolas is a good programmer's font. You can download it freely from Microsoft. But to install it you need Visual Studio installed. But here I'll show you how to install it without having VS installed.
1. Download the original font setup from the Microsoft website.
2. Download and install Orca. Orca is a Windows Installer package editor.
3. Now run the consolas installer. You'll get an error message. But don't close the installer. Instead navigate to your %temp% directory and you'll see a (random_string).msi file. Copy it to another directory and exit the installer.
4. Right-Click the now obtained msi file and choose "Edit with Orca".
5. In Orca, in the left pane look for "LaunchCondition".
6. Toggle the value of "IS_VSS_INSTALLED". (Or you can just right-click the row and choose "Drop Row").
7. Save the changes, close Orca and run the patched installer.

Wednesday, September 29, 2010

FlashBuilder 4 JVM Terminated Exit Code = -1

Everything was fine until now. After a system restart, I had this stupid error popping up when ever I try to start Flash Builder. I had modified the FlashBuilder.ini file and it worked fine for weeks.
If you get such an error, first thing you need to keep in mind is its Java. So you are expected to see such things. Next, go to the FlashBuilder install directory and open up your FlashBuilder.ini file.
Check whether the -XX:MaxPermSize is same as the -Xms and is less than -Xmx.
Here is mine.
If this still don't work, then first make a backup of FlashBuilderC.ini. Then you can run FlashBuilderC.exe and see whether it starts. If it starts then compare the values in it to that of FlashBuilder.ini and make the modifications to FlashBuilder.ini.

Friday, September 3, 2010

Download videos from Adobe TV (tv.adobe.com)

In order to download videos from tv.adobe.com the traditional way is to use the Adobe Media Player and sign in. Add the video to your library or rss etc and it downloads for offline viewing.
But to see your library you need to login. But there is some bug in Adobe Media Player so I get "We are sorry.." message soon after signing in. So basically it doesn't work for me. We could download the video by following the below steps.
1. You need URLSnooper.
2. Install it. Make sure that you install winpcap which comes along with it.
3. Open URLSnooper and in the menu click advanced. Then select your network adapter.. etc
4. Click sniff network. In the protocol filter let it be Multimedia URLs.
5. Then open your browser and go to the http://tv.adobe.com/.. video page (and let the video start to play).
6. Now you will see some links appear in the sniffer (URLSnooper).
7. They are actually http links.
8. Also note that the videos are mostly hosted on edgeboss.net servers.
9. Now you will see some links like (ignore the {} brackets) http://adobe.edgeboss.net/download/adobe/adobetv2/360_flex_conference/{some_string_video_name}.flv?rss_feedid={a_number}&xmlvers=2
10. There it is!! So the url is http://adobe.edgeboss.net/download/adobe/adobetv2/360_flex_conference/{some_string_video_name}.flv
11. Copy and paste it in your browser. Download it. Watch them offline!!

Saturday, July 17, 2010

Setting up MySQL with Ruby on Rails in Windows

1. Download MySQL Community Server (latest is 5.1.48) and install it.
2. In the console type
gem install mysql
This installs the mysql adapter for ruby.
With rails 2.2 or later (mine is 2.3.8),  MySQL 5.1 in windows doesn't integrates well.
3. So to avoid problems download libmySQL.dll. This is an older version of MySQL client library. Copy it into the ruby\bin folder.
This avoids error during rake db:migrate which might cause
rake aborted!
Mysql::Error: query: not connected: CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
4. You can install the MySQL GUI Toolkit (optional).

Friday, July 16, 2010

mxmlc Error Loading: "D:\Program Files\Java\jre6\bin\server\jvm.dll"

mxmlc which is the flex compiler requires that you have Java Runtime Environment installed in you system which in particular must be 32 bit (at present). The error - Error Loading: "D:\Program Files\Java\jre6\bin\server\jvm.dll" is shown means you are having a 64 bit JRE. You need to point to a 32 bit version. Open the Environment Variable window and configure as shown in the screenshot.

Create a new variable called JAVA_HOME with value pointing to the 32 bit version of JRE. In my case its D:\Program Files (x86)\Java\jre1.6.0_07\
Now mxmlc should work.

Saturday, July 10, 2010

Install Ruby on Rails in Windows 7

Installing Ruby on Rails in Windows is very easy.
1. Goto download section of www.rubyonrails.org
2. Check the recommended version for ruby to be installed.
At present the recommended version is Ruby 1.8.7.
3. Download Ruby 1.8.7  (preferably Ruby 1.8.7-p249 RubyInstaller).
4. Download RubyGems. You can download the latest one. (ruby-gems-1.3.7.zip)
5. Install Ruby. (You must check set environment path during installation.)
6. Extract ruby-gems and navigate to the extracted folder using cmd.
7. Inside the ruby-gems folder type:
ruby setup.rb
8. Now RubyGems is installed.
9. Now you can simply run
gem install rails
to install rails.
Its found that there are some problems with Ruby1.9.1 with rails (in Ubuntu). However Ruby 1.8.7 works fine.

Install wget for windows and set environment path

1. Download Windows binaries of wget.
2. Extract it to to say D:\Utils\ (you can put it where ever you want).
3. Right-click Computer under the start menu and choose Properties.
4. On the left pane click Advanced System Settings and choose Environment Variables.
5.  In the 'User Variables' section (the upper part), create new variable named Path if it doesn't exist.
6. For that click the New button, give the name value Path and variable value the location of the wget folder. In our case its D:\Utils
But if the Path variable is already present, add a semi-colon at the end and then specify the location of wget.exe.

Tuesday, July 6, 2010

Register your IRC Nickname

In order to register your irc nickname with the Nickserv, login to an irc channel.
Here I use a web based client for making this process simple and easy.
1. Goto http://webchat.freenode.net
2. Enter the nickname you wanted to register and any irc channel, say #python and click connect.
3. If it isn't already owned you will see a page with logs and at the bottom you can type messages. This is the status page tab. After a while you will see the #python page.
4. Click the status tab and enter /msg Nickserv REGISTER password email
where passwordis the password you want and an email to confirm the nickname. Confirmation message will be sent to your email.
5. Open your mail and follow the instruction.
6. The verification format will be of the form /msg NickServ VERIFY REGISTER yournickname verificationcode

If you don't want to make your email public then enter /msg nickserv set hidemail on.
To set nick to private mode set /msg nickserv set private on so that list command does not show the nick.

Once identified with the server, to change password use /msg nickserv set password $newpass

Note that you need to log in atleast once in 60 days to prevent the username from being inactive.
Ref: IRC Beginner's commands

wget websites

wget utility can be used to save websites for offline viewing.
wget --no-parent -rkpU Mozilla http://examplewebsite.com/index.html
--no-parent does not fetch files from parent directories.
-r recursively downloads the pages. Means if the index.html contains links to .css files and other pages those will be downloaded.
-k convert-links The links that appear in a page will be pointed to local files
-p page-requisites Get all images etc needed to display the html page.
-U Mozilla U means user-agent and Mozilla is one of the user-agents. Some sites allows only user-agents identified as browsers only since they don't want the sites ripped.

Sunday, July 4, 2010

Fix sound in Ubuntu 10.04

With the installation of Ubuntu 10.04, most probably the sound won't work by default. You can see the a red icon as shown in the picture below. Click the sound icon and choose unmute. Done.

Tuesday, June 1, 2010

How to Use Usenet Groups Effectively

Usenet groups can be accessed using variety of methods. One way is to use Google Groups to access them. But the disadvantage here is that you will see all the spams and its really difficult especially navigating comp.lang.lisp group. Here I'll show how to access them effectively without those stupid spams. Thanks to comp.lang.lisp guys for helping me get this clear.
1. You need to use a new reader client. You can choose anyone for eg. Thunderbird, Windows Live Mail, Microsoft OutLook etc.
Here I'll show how to use Windows Live Mail to access newsgroups.
2. If you are using Windows 7, you need to download Windows Live Mail.
3. When running Windows Live Mail for the first time it will ask for an email account. Configure it since an account is need to post to newsgroups.
4. Goto eternal-september.org and register there. Remember the username and password. We will be accessing newsgroups using this server. This server will effectively weed out spams and make out lives a lot more easier.
5. Next at the bottom of the Windows Live Mail you'll see the Newsgroup option. Click on it and on the left pane you will see 'add newsgroup'.
6. Click on it and a dialog pops up. Follow it till the end. Well, at first you need to enter a display name.
7. Next add the above email address.
8. Next add the news (NTTP) server as news.eternal-september.org and tick the box which says "My news group requires me to log in".
9. Next enter the username and password that you used to register at eternal-september.org
10. The rest will be taken care by the application. It will test the connection, download the list etc.
11. Done.

NB: After 150 days of inactivity eternal-september.org will sent you a warning message. Further inactivity will lead to deletion of your registered account.
Don't use top-posting. Read this guide on "How do I quote Correctly in Usenet?"

Cannot find or open the PDB file

Running Visual Studio 2010 in Windows 7 64 bit gives messages "Cannot find or Open the PDB file" as show in the figure below. Its because you are running it as a normal user. You need to run it as an Administrator to stop showing the warning. For that right-click VS 2010 and choose Run as Administrator.

Thursday, May 6, 2010

Access Document Class in ActionScript 3.0

Consider a case where there are two classes called Main, and Other. The class Main is the Document Class, which has instantiated an object of the class Other. Here for the Class Other to access the methods of the class Main, can be easily done by creating an instance which is a static variable of the class Main which can be called only through the class. Static variables are associated with a class and not with instance of the class.
See example below:
package {

import flash.display.Sprite;

public class Main extends Sprite
public static var mainInstance:Main;
private var _child:Other;

public function Main()
mainInstance = this;
_child = new Other();

public function foo():void
trace("hello from document class");

package {

import flash.display.MovieClip;

public class Other {

public function Other()

You can use getter if you don't want to expose the variables.

Friday, April 23, 2010

Runtime Shared Library (RSL)

Runtime Shared Library (RSL) is similar to a DLL in Windows. It can be used by multiple applications that uses same code. RSL are of various types like standard, cross-domain, framework RSLs.
Framework RSL are reduce app size & is signed by Adobe. Its secure but can be used with applications made with Flex framework that are deployed as web apps. The framework RSLs are cached by the player. It reduces the app size to around 30% with Flex 4 framework.
It reduces the bandwidth, but increases the loading time of the application since the whole library will be loaded.
Generally there is no point in using RSL (framework RSL) with AIR apps. For AIR apps the best way is to choose 'merged into code' option where only the referenced classes are included with the final swf.

Tuesday, April 20, 2010

Change the position of window control buttons in Ubuntu

With the upcoming version of Ubuntu (v 10.04 Lucid) the window control (minimize, maximize, close) buttons are placed at the left like in Mac OS. To change their position,
1. Open terminal or use ALT+F2
2. Type gconf-editor
3. Navigate to apps -> metacity -> general
4. You will find a key button_layout with value close,minimize,maximize:
5. Change the order of them as you like (experiment a bit)
6. Done

Wednesday, April 14, 2010

Navigate Folders with Spaces Using Terminal

To navigate using a terminal; through folders containing spaces in a GNU/Linux environment,
1. escape the spaces
cd /documents/spaced\ folder/
folder name: spaced folder. It can be escaped as spaced\ folder
2. give the path in quotes
cd '/documents/spaced folder/'

Read-Write Permission for a File in GNU/Linux

To have complete read-write access over a file in GNU/Linux, in terminal enter
sudo chmod 777 filename
Note that you need the privilege to change permissions. The chmod 777 will give complete read-write access on that file (or folder) to the current user.

Delete a File from Google Code

In order to delete a file from Google Code, click on the summary tag (Summary + Labels) of the particular file. Now you will be shown a page where there is a button to delete the file. Its that simple.

Import a Flex Builder 3 Project in Flash Builder 4

To import a Flex Builder 3 project file in Flash Builder 4 follow the steps below:
1. Choose File -> Import -> Other
2. General -> Existing Projects into Workspace; and click next
3. Select the root directory or archive file; and click browse. Locate the previous Flex Builder 3 project.
4. Finish

While importing Choose the default SDK (Flex 4), and check the Use Flex 3 Compatible mode.

Friday, April 9, 2010


This is an AI chatbot, which is an AIR app written in ActionScript 3.0. It features interactivity and learning capabilities. Currently the learning should be supervised. It tries to maintain the state (context) of the conversation too. It can be classified as an expert system, but currently it isn't focused on any particular domain. It is generic in nature.

I acknowledge the helping members at KirupaForum and Adobe Forums

Friday, April 2, 2010

Settings for Ripping Sprites in Flash

Under Modify -> Bitmap -> Trace Bitmap
Color threshold: 20
Minimum area: 1 pixels
Curve fit: Pixels
Corner threshold: Few Corners.
These settings will make ripped sprites look better.

Thursday, April 1, 2010

Adobe AIR error 303

When Exporting the release build of your AIR application using Adobe Flex Builder if you get and Adobe AIR Error 303, it implies that the problem is with your icons.
Most probably the problem might be due to pointing the icon to the wrong folder.
src is the root folder.
Suppose your icon is in a folder called assets inside the src folder, then inside the app descriptor, the path should be like
If you don't have say a 16 px icon then remove that node instead of leaving it blank.

Sunday, March 28, 2010

Enhancement in Windows Media Player 12

To choose equalizers or other enhancements in Windows Media Player 12 that comes with Windows 7,
1. Press Alt, then choose skin mode or now playing mode under view.
2. Press Alt, then you will see enhancements option inside view.
If in normal mode you won't see the enhancements.

Friday, March 19, 2010

Install Adobe AIR in Ubuntu

1. Download Adobe AIR for GNU/Linux to the home directory.
2. The file name is AdobeAIRInstaller.bin
3. Change mode the file for execute.
chmod +x AdobeAIRInstaller.bin
4. Run
sudo ./AdobeAIRInstaller.bin
which will bring the Adobe AIR Setup-installation window.
Alternatively you can use
sudo sh AdobeAIRInstaller.bin
to bring up the installation window.
5. Done

Sunday, January 10, 2010

Read ID3 Tag of an mp3 File using ActionScript 3.0

ID3 tags are embedded within an mp3 file that stores the metadata. It contains various information such as the title, artist, album, track number, and other information about the file.
Here we will see how to read those information using ActionScript 3.0 and Flex Builder 3.0 as the IDE.
package {
import flash.display.Sprite;
import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.text.TextField;

public class ID3Tag extends Sprite {
private var _sound:Sound;

public function ID3Tag()
_sound = new Sound();
var _soundURL:URLRequest = new URLRequest("sound/4one-Surrealism.mp3");
_sound.addEventListener(Event.ID3, readID3);

private function readID3(event:Event):void
var tf:TextField = new TextField();
tf.appendText("\nArtist: "+_sound.id3.artist);
tf.appendText("\nAlbum: "+_sound.id3.album);

Now I shall explain the above.
The folder organisation is as below.
public function ID3Tag()
_sound = new Sound();
var _soundURL:URLRequest = new URLRequest("sound/4one-Surrealism.mp3");
_sound.addEventListener(Event.ID3, readID3);
ID3Tag() is the constructor. We need to load the mp3 which is inside the sound folder. URLRequest is used to point to the file which inturn is loaded using the load method.
We now add an eventlistener which listens to Event.ID3. What this does is if there is an ID3 tag present for the loaded mp3 file, then the corresponding readID3 function will be called.
private function readID3(event:Event):void
var tf:TextField = new TextField();
tf.appendText("\nAlbum: "+_sound.id3.album);
tf.appendText("\nArtist: "+_sound.id3.artist);
We create an new TextField tf which is added to the stage. tf.appendText() method is used to display the tags. _sound.id3 is the method that parses the ID3 tag for us. And the _sound.id3 method contains various properties like album, artist, comment, genre etc. The _sound.id3.album will show the name of the album and likewise.

An updated version of this tutorial can be found at Kirupa.com

Tuesday, January 5, 2010

Crack your Windows Password

Here I'll explain how to audit the windows password using Backtrack GNU/Linux and John The Ripper. This case study will be using windows xp professional. However the procedure is same for newer versions.
This method is purely brute-force and will take time depending on the password complexity and the system configuration.

1. Equip yourself with the BackTrack live Cd.
2. Boot your system with the BackTrack Live Cd.
3. Start the x-server (i.e, GUI mode)
4. Fire up your terminal.
5. Type in at the prompt:
bkhive /mnt/sda1/windows/system32/config/system sys.txt
You'll see some data given out to the terminal like Bootkey..
samdump2 /mnt/sda1/windows/system32/config/sam sys.txt > pass.txt
In the above code, samdump2 dumps the SAM (System Accounts Manager) file that contains the user information to a file called pass.txt
sda is used assuming that the hard disk is a SATA. sda1 is used assuming windows is installed to the first partition of the hard disk. hda is to be used if its an IDE hard disk.
6. Open John The Ripper from the Backtrack KDE menu (analogues to start button in windows) and run the command:
john /root/pass.txt
Wait until John cracks the password.
If its finished cracking it will show a message. You can press any key to see the current progress, word combination, etc.
7. To show the cracked passwords type:
john show /root/pass.txt
And there you go!

Monday, January 4, 2010

No Shadow for Icons in XP

If there appears no shadows for icons in XP even after enabling the "Use drop shadows for icon labels on the desktop", then it implies that the problem is caused due to the wallpaper.

The reason is that the image is having more than 8 bits/Channel. And since XP doesn't have desktop compositions as like in the newer versions of Windows like Windows Vista, Windows 7, it cannot render images greater then 8 bit/Channel. Also some pngs can cause it as well. So the solution to this is to change the wallpaper or make it 8 bit/Channel.

Lisp Programming using Eclipse IDE

Eclipse IDE can be used for LISP programming, other than emacs, obviously.

1. Download Eclipse Classic IDE.
In order to run eclipse java runtime should be installed. There are both 32 and 64 bit versions of JRE and Eclipse. Choose them depending on the OS that you use. Extract the archive.
2. Download cusp plugin depending on the OS and extract it.

The folder structure is as below for windows version
  \-- features
  \-- plugins

4. Copy the contents inside the features and plugins folder of the cusp_win32 to the corresponding features and plugins folder which is present inside the eclipse-SDK-3.5-win32\eclipse folder.

Now open the eclipse IDE and under the window->Open Prespective->other... we will see Lisp. Choose it, and now we have a full blown Lisp IDE.

Friday, January 1, 2010

USB 3.0

USB 3.0 also called as SuperSpeed USB will be available soon on ASUS and gigabyte motherboards. ASUS has also announced an add-in PCIe x4 card with USB 3.0 support, though it is compatible only with its P55 series of motherboards after a BIOS upgrade. Fujitsu is about to release laptops with USB 3.0 support. But Intel has announced that it will not include USB 3.0 in its chipsets until 2011. AMD may not support USB 3.0 until 2011 either. It may be available with Apple products in early 2010. GNU/Linux is the first Operating System with official USB 3.0 support.

1. SuperSpeed - transfer mode at 4.8 Gbit/s
USB 3.0 achieves those speeds with a new plug and cable format, but it's all backward-compatible with USB 2.0 and USB 1.1.
2. Full-duplex: Devices can send and retrieve data simultaneously
3. Support for streaming
4. Improved power management - idle, sleep and suspend states.

There is a 127 device limitation per controller.