msgfmt -o [output_file]
Wednesday, December 01, 2010
Create a .mo file from .po file for i18n
msgfmt -o [output_file]
Monday, November 29, 2010
Don't require password for sudo
$ sudo visudo #add desired username to the file in the following format:
Wednesday, November 10, 2010
Enable color-coding for diff in TextMate
However, you may be missing the nice coloring in the newly opened window that is supporte by TextMate by default. As it often is the case, getting this to work is easy but you first need to find how to get there. So, to toggle the coloring, simply press Ctrl+Option+Shift+D (if this does not work on your system, go to Bundles->Bundle Editor->Show Bundle Editor click on Diff bundle. In the Activation text field is the keyboard shortcut you can use to toggle color coding for diff). Enjoy!
Wednesday, September 01, 2010
Profile SGE queues
Saturday, July 10, 2010
Replace entire line that contains given text
Say the string you are looking for is STRING_TO_BE_REPLACED.
And the line you want to insert is LINE_TO_REPLACE_WITH.
sed 's/^.*STRING_TO_BE_REPLACED.*$/LINE_TO_REPLACE_WITH/' input_file > new_file
The ^ is a start of line anchor, the '.*' is a wildcard, the $ is a end of line anchor.
Tuesday, February 02, 2010
Unable to find a $JAVA_HOME at … on Mac OSX
>java -version
Unable to find a $JAVA_HOME at “/usr”, continuing with system-provided JavaI tried setting the environment variable
JAVA_HOME=/usr but the error remained when running java.I found the following solution here:
First, find out where java actually is:
>ls -l' `which java`
/usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javaI noticed a command called java_home in that same directory. Running that command yields the correct java home directory.
>/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/HomeTo correctly set the my JAVA_HOME environment variable in future, I added the following to my
~/.profileexport JAVA_HOME=`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home`Restart terminal and enjoy.
Wednesday, January 27, 2010
Prepend every line in a file with some text
p1-c-b-1.fastq.gz
p1-c-b-2.fastq.gz
p1-c-c-1.fastq.gz
Now, you would like to add a full URL path to each of those lines, prepending existing text.
Use awk as follows:
$ cat files.txt | awk '{ print "http://www.complete.url.com/", $0; }' > links.txt
You get a file names 'links.txt' looking like this:
http://www.complete.url.com/ p1-c-b-1.fastq.gz
http://www.complete.url.com/ p1-c-b-2.fastq.gz
http://www.complete.url.com/ p1-c-c-1.fastq.gz
To get rid of introduced extra white space, use sed:
$ cat links.txt | sed 's/ //g'
Tuesday, January 26, 2010
Monitor network traffic on OpenSolaris from command line
# netstat -i 1
input xnf0 output input (Total) output
packets errs packets errs colls packets errs packets errs colls
1111615 0 745655 0 0 1111684 0 745724 0 0
399 0 306 0 0 399 0 306 0 0
416 0 343 0 0 416 0 343 0 0
To expolore actual packets crossing the network, use snoop command. It captures both TCP and UDP traffic. It is a tool that is shipped with Solaris.
Here is sample output:
# snoop
Using device xnf0 (promiscuous mode)
cbcb-vs.umiacs.umd.edu -> domU-12-31-39-04-EC-47.compute-1.internal TCP D=60088 S=8021 Ack=4204280156 Seq=2401233531 Len=1460 Win=92
domU-12-31-39-04-EC-47.compute-1.internal -> cbcb-vs.umiacs.umd.edu TCP D=8021 S=60088 Ack=2401246671 Seq=4204280156 Len=0 Win=49640 Options=
domU-12-31-39-04-EC-47.compute-1.internal -> dhcp243113.rollins.emory.edu TCP D=49769 S=22 Push Ack=4234202219 Seq=2467318705 Len=192 Win=49232
It shows source and destination servers, type of traffic, source and destination ports, as well as some packet info.
Friday, December 18, 2009
Add folder to Places sidebar in Mac Finder
To remove the folder from the list, right click it in the sidebar and select "Remove from sidebar".
Saturday, December 12, 2009
Digital Color Meter in OS X
Wednesday, December 02, 2009
Replace multiple spaces/tabs with single space
Wednesday, September 09, 2009
Installing Xen dom0 on Ubuntu 9.04

As shown in the figure, and contrary to my prior belief, Xen hypervisor is represented by another GRUB entry at system boot time (as opposed to simply replacing the OS that it was installed from). As a result, you can choose to boot into original OS without Xen availability or into the Xen system even after you have installed Xen on given system. This was just used to show a high-level picture of system layout...
Following are a set of commands that will install Xen hypervisor. These commands are to be executed within the original OS currently existing on the machine:
$ wget http://http.us.debian.org/debian/pool/main/l/linux-2.6/linux-image-2.6.26-2-xen-686_2.6.26-19_i386.deb
$ wget http://http.us.debian.org/debian/pool/main/l/linux-2.6/linux-modules-2.6.26-2-xen-686_2.6.26-19_i386.deb
$ sudo dpkg -i linux-modules-2.6.26-2-xen-686_2.6.26-19_i386.deb
$ sudo dpkg -i linux-image-2.6.26-2-xen-686_2.6.26-19_i386.deb
$ sudo apt-get install ubuntu-xen-server
Name ID Mem VCPUs State Time(s)
Domain-0 0 702 1 r----- 312.9
Friday, August 14, 2009
Adding new disk to ZFS
When initially instantiating and setting up accounts on ZFS filesystem (in my case, under OpenSolaris 2009.06), it is beneficial to store user data on a pool other than root pool (i.e., rpool). This is because rpool cannot be composed from multiple hard disks and thus cannot be changed in size (unless it is mirrored) [ref].
So, start by adding a disk to the machine and creating a pool from it.
The following commands lists names of disks available in the system:
afgane@opensolaris:~$ pfexec format
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c7d0
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
1. c7d1
/pci@0,0/pci-ide@1,1/ide@0/cmdk@1,0
2. c8d1
/pci@0,0/pci-ide@1,1/ide@1/cmdk@1,0
Specify disk (enter its number): ^C
afgane@opensolaris:~$
From this, we see that the above system has three disks: c7d0, c7d1 and c8d1
NOTE: Instead of creating a filesystem on a physical disk, you may create it from a simple file that exists in current file system. To do this, create a file on the system of desired size and use it instead of the disk name. Use the following command:
afgane@opensolaris:~$ dd if=/dev/zero of=myfile bs=1024 count=10
This command creates a file called "myfile" filled with zeros with a block size of 1000 multiplied 10 tens or 10K (i.e., created file of size 10K bytes).Before seeing which of the disks is being used by which pool, we need to see what pools are available on the machine. Do so by issuing the following command:
root@opensolaris:~# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
rpool 34.8G 3.79G 31.0G 10% ONLINE -
root@opensolaris:~#
From this output we can see that there is only one pool available on the machine, namely rpool.
Next, in order to see which disk is being used by rpool, issue the following command:
afgane@opensolaris:~$ zpool status
pool: rpool
state: ONLINE
scrub: none requested
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
c7d0s0 ONLINE 0 0 0
errors: No known data errors
afgane@opensolaris:~$
This tells us that disk named c7d0s0 is used by rpool.
We can now create a new pool and add one of the two extra disks that are available in the machine to this newly created pool. Do so by executing following command (note that you must be root to issue this command):
root@opensolaris:~$ zpool create myPool c7d1
We can now see our newly created pool and can access it as a regular directory on the machine:
root@opensolaris:~# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
myPool 1.95G 32.7M 1.92G 1% ONLINE -
rpool 34.8G 3.79G 31.0G 10% ONLINE -
root@opensolaris:~#
root@opensolaris:~# cd /myPool
If you ever add another disk to this machine, it is very simple to add it to the overall pool of available space. We will use the third disk that is available in this machine, as follows (remember that you need to be root to issue this command):
root@opensolaris:~# zpool add myPool c8d1
And here is the list of the new pool arrangement, showing the increased pool size:
root@opensolaris:~# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
myPool 2.95G 32.7M 2.91G 1% ONLINE -
rpool 34.8G 3.79G 31.0G 10% ONLINE -
root@opensolaris:~#
Wednesday, June 10, 2009
Add 2nd disk in VMware
2. Boot the guest OS and go to Control Panel->Administrative Tools->Computer Management->Disk Management
3. Right click the new partition and initialize it.
Thursday, April 23, 2009
Quickly toggle tab swap preference for TabMix Plus
Monday, December 08, 2008
Adding a tag in subversion through subclipse
Create a message in the branch/tag comment area. If you would like to continue to work in your current working copy then leave the “Switch working copy to new branch/tag” checkbox clear. If you would like to switch so that you can make additional modifications to the branch/tag without changing the current working copy then select this checkbox.
Click OK in order to create the branch or tag.
Friday, December 05, 2008
Adding a computer to subversion repository (through subclipse)
Assume there is a subversion repository already in place with documents in it. The repository was established with a certain version of documents from computer ONE. At the same time, computer TWO has a copy of those documents and it is not connected to the repository. Documents on computer TWO are edited before connecting the computer to the repository. Now, I would like to create a connection from computer TWO to the repository but I cannot simply issue a 'checkout' command because documents on computer TWO are the more recent version of the ones that are in the repository. While one would think this is a simple task (for a beginner w.r.t. subverion at least), it is not!
In order to achieve desired functionality, the following can be done (all of these are done on computer TWO):
1. From Windows Explored, move entire contents of the project directory to some temporary directory
2. From Eclipse (i.e., subclipse), checkout the desired project (go to SVN Repository Exploring perspective, browse to the desired project, right-click on trunk, tag (or similar) directory that wants to be checked out within the browser, and select Checkout)
3. Follow the checkout wizard and chose to 'Check out as a project in the workspace' and give it the name that matches the desired project name. After clicking Finish, it will tell you that the specified project exists and contents will be deleted. Click OK.
4. After checking out the documents has completed, go back to the Windows Explorer and copy contents of the temporary directory into the project directory
5. Refresh the project tree view in Eclipse. Right-click project name in Eclipse and select Team->'Synchronize with Repository'. This will open Team Synchronizing perspective (or ask you to do so) and show you differences from the new document versions with the ones in the repository.
6. Commit the new version into the repository by selecting documents, right-clicking and choosing Commit command.
From now on, both of the computers should be able to update/commit changes as needed.
If anyone reads this and knows a better way of doing it, please leave a comment explaining how because, in my current opinion, whoever designed document repositories to have the interface different from that of a simple drag&drop is an idiot.
Wednesday, September 10, 2008
Installing kinship library for R
Save it anywhere.
From the directory where the library was saved, issue command: R CMD INSTALL kinship_1.1.0-21.tar.gz
Upon completion, you can type R to start the application and then issue command: library(kinship)
Note, for a system wide installation where one does not have access to installation paths for R, additional steps are needed:
Create a directory where extra libraries will be saved (e.g., extraLibs in $HOME)
Then, set the R_LIBS var in ~/.bashrc and you should be set.
Friday, August 29, 2008
Installing R
2. Untar the downloaded archive using command: $ tar -xvzf [R-version.tar.gz]
This will create a new directory named ./[R-version] in the current directory.
3. Enter newly created directory: cd [R-version]
4. Issue command: ./configure --prefix=/path/to/install (e.g., /home/afgane/R/[R-version])
In order to link BLAS and CLApack libraries, the following set of commands can be used (the export statements specify desired compiler, also make sure library paths are edited to match current resource):
export CC=icc
export CXX=icpc
./configure --prefix=/store/R/R-2.7.2 --enable-threads=posix --with-blas="-L/opt/intel/cmkl/10.0.011/lib/em64t -lmkl -lguide -lpthread" --with-lapack="-L/opt/intel/cmkl/10.0.011/lib/em64t -lmkl_lapack"
5. Type tow following commands to make and install:
$ make
$ make check
$ make install
Setting up SSH keys for authentication without passwords
2. Issue command: ssh-keygen –t rsa
3. Change into ~/.ssh directory
4. Copy contents of file id_rsa.pub from machine ONE to file ~/.ssh/authorized_keys on machine TWO. Note, if this file already exists, simply add a new line to the bottom of it. Furthermore, make sure that the key being copied is all on one line.
5. Change permissions of ~/.ssh/authorized_keys on machine TWO to 700
6. Now, you are able to log in from machine TWO to machine ONE without a password