Tuesday, 24 May 2011

Co-routines in Python

Co-routines are very interesting subject in python which enables several routines to feed into each other very similar to unix piping. The good point of this approach is that each routine gets executed onces each bit of data is required. So it is very effiecient in terms of CPU and memory usage. Following link is a great resource on this subject.

http://www.dabeaz.com/coroutines/

Friday, 20 May 2011

Postgresql 9.0 and ident

I was trying to create some monitoring tool for new postgresql 9.0 in a project on RHEL. Spent couple of hours tweaking hba file with no effect! Quite disturbing! Then I found the file was somewhere else due to difference between the 9.0 rpm and the original RH one! Here is the command to find it. Quite useful:

postgres=# show hba_file; 
              hba_file             
-------------------------------------
 /var/lib/pgsql/9.0/data/pg_hba.conf
(1 row)

I found it in this blog, quite other nice things in it.

Saturday, 14 May 2011

Best wireframe application mockup tool

For a long time, I have been looking for the best and most flexible application UI design tool for rapid prototyping and wireframing. I noticed there weren't any well rounded one available. Either they were too complicated which eventually made me think using a proper IDE like Visual Studio or Ecpilse would be far easier or they lack essential features. For example, they were only for web applications and not desktop or vise versa or didn't support mobile apps or they weren't very expandable. Thus I resorted to use very basic diagramming tool which was actually very effective and more importantly free and opensource called Diagram Designer .
This was all until I found Balsamiq. I must admit this was really great! Far better than what I thought. Very simple, elegant UI, done in Adobe AIR which meant could be run in the browser or outside on all widely used platforms. It supports web apps, desktop, mobile(iphone and android) with loads of control libraries plus a nice community which contribute more controls. Welldone Balsamiq!

Wednesday, 11 May 2011

Software codemanship

Developing software is an art. Jason from Codemanship have excellent experience and knowledge which tries to share. Following is the list of interesting links related to this matter:

Monday, 9 May 2011

Automaticly build VM machines with VirtualBox

There is nice budding project Vagrant which automates the process of creating VMs. I haven't yet experiment with it. But it is an interesting thing to know of.

Friday, 6 May 2011

Juniper JunOS and Cisco IOS emulators

This little beauty http://dynagen.org/tutorial.htm, can run the actual IOS image! and it works fully like a router, routing packets!

The same exist for Juniper http://juniper.cluepon.net/index.php/Olive which can be run even under VMWare http://routerjockey.com/2009/10/03/running-junos-under-vmware/ but these don't include routing engine.

Sunday, 1 May 2011

Linux command tips

As I am getting older and my memory sometimes fails embarrassingly, I decided to dedicate this post for some useful bits and peaces here and there which saves a lot of time.

Find
Is an extremely useful utility specially when used with proper piping.
# This will search for the word 'xml' in every file under
# current folder that starts with . (hidden dirs)
kibo@kibo-UbuntuVM:~$ find . -regex '^.\/\..*' -exec grep xml {} \;

# Now to limit the search to directories and only first level
kibo@kibo-UbuntuVM:~$ find . -regex '^.\/\..*' -type d -prune

# To do inverse selection(everything but the ones you selected)
kibo@kibo-UbuntuVM:~$ find . -regex '^.\/\..*' -type d -prune -o -print

# Thus interestingly following prints only files not folders
kibo@kibo-UbuntuVM:~$ find . -type d -o -print

# Search everything except Desktop folder
kibo@kibo-UbuntuVM:~$ find . -path Desktop   -o -print

# Lists all symbolic links from current path downwards
kibo@kibo-UbuntuVM:~$ ls -l `find . -type l`

# List all broken symbolic links from current path downwards
kibo@kibo-UbuntuVM:~$ find -L . -type l

# List all directories with maximum 2 levels of depth
kibo@kibo-UbuntuVM:~$ find . -maxdepth 2 -type d

# Global search and replace! Very handy indeed
kibo@kibo-UbuntuVM:~$ find ./Desktop -type f -exec sed -i 's/hello/goodbye/g' {} \;


Ls
Very basic command but the most useful!
# List all directories nicely!
kibo@kibo-UbuntuVM:~$ ls -ldr */
drwxr-xr-x 2 kibo kibo 4096 2011-04-30 23:36 Videos/
drwxr-xr-x 2 kibo kibo 4096 2011-04-30 23:36 Templates/
drwxr-xr-x 2 kibo kibo 4096 2011-04-30 23:36 Public/
drwxr-xr-x 2 kibo kibo 4096 2011-04-30 23:36 Pictures/
drwxr-xr-x 2 kibo kibo 4096 2011-04-30 23:36 Music/
drwxr-xr-x 2 kibo kibo 4096 2011-04-30 23:36 Downloads/
drwxr-xr-x 3 kibo kibo 4096 2011-05-01 11:02 Documents/
drwxr-xr-x 2 kibo kibo 4096 2011-04-30 23:36 Desktop/
drwxr-xr-x 3 kibo kibo 4096 2011-05-01 11:02 Aptana Studio 3 Workspace/
drwxrwx--- 9 kibo kibo 4096 2011-05-01 21:35 Aptana Studio 3/

Ps
Good during trouble shooting along with top and nmon!
# Lists all python processes with first column(pid)
# and fourth column(cpu time)
kibo@kibo-UbuntuVM:~$ ps fax | grep python | awk {'print $1,$4'}

Rsync
Syncing two directories through SSH
rsync -av -e ssh /blah/*  host105:/opt/blah/blah 

netstat
Lists every single open port based on PID
netstat -taucp

VirtualBox and Guest Ubuntu shared folders

If you have used VirtualBox with host and guest windows, then you know that it has very nice automounting shared folders feature. The same feature is now available for Linux based guests. But there is a hitch. For your user to be able to access the shared folder, you would need to be added to vboxsf group as the permissions don't allow you to see the shared folder. By the way, all shared folders are automounted under /media/sf_<sharedfolder name>.

root@kibo-UbuntuVM:~# ls -l /media/
total 16
drwxrwx--- 1 root vboxsf 16384 2011-04-30 22:59 sf_Shared

root@kibo-UbuntuVM:~# useradd -G vboxsf [your gnome session user]

Or alternatively you can add an existing username in /etc/group file at the end of line which starts with vboxsf.

ensure you logout and login again and voilĂ !