Wednesday, November 28, 2012

Install VirtualBox in Ubuntu 12.10


  1. echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
  2. wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
  3. sudo apt-get update
  4. sudo apt-get install virtualbox-4.2

Saturday, November 17, 2012

How to send an email using telnet

> telnet youremailsever.com 25

# handshake
helo youremailsever.com

# set from
mail from: sender@email.com

# set to
rcpt to: receiver1@email.com

# set cc if you want to send the email to multiply receivers
rcpt to: receiver2@email.com

# email content
data
# show in the email
from: sender
to: receiver
cc: receiver1; receiver2; ...
subject: hello world
date: 17 Nov 2012
hello world!
# need "." in a separate line to terminate the email content
.

# quit telnet connecton
quit

Saturday, November 10, 2012

Making Eclipse's Java code formatter ignore comments

Use /*- (note the hyphen) at the beginning of the block comment, and the formatting won't be affected if you format the rest of the file.

/*- 
 * foo
 *    line1
 *        lin2
 */

Friday, November 9, 2012

Extract one file from tarball archieve

1. extract foo.txt from foo.tar.gz

  tar -zxvf foo.tar.gz foo.txt

2. extract path/foo.txt from foo.tar.gz

  tar -zxvf foo.tar.gz path/foo.txt


3. extract path/foo.txt from foo.tar.gz to dstpath

  tar -zxvf foo.tar.gz -C dstpath path/foo.txt


3. extract path/foo.txt from foo.tar.gz to dstpath, without creating directory

  tar --transform 's/.*\///'  -zxvf foo.tar.gz -C dstpath path/foo.txt

Wednesday, November 7, 2012

Sort Nautilus Bookmarks

If only locations are provided:

sort ~/.gtk-bookmarks -o ~/.gtk-bookmarks

If names are provided:

sort ~/.gtk-bookmarks -o ~/.gtk-bookmarks -k 2


Thursday, November 1, 2012