Mount an ISO file in Linux
1 # mkdir /mnt/iso 2 # mount -o loop -t iso9660 file.iso /mnt/iso
Jump start a Rails project with Rails Edge, Capistrano, Mongrel and Mercurial
1 # Create a Rails project 2 rails project -d sqlite3 3 cd project 4 # Delete index file 5 rm public/index.html 6 # Use Rails edge. Use rake rails:freeze:edge TAG=rel_1-2-3 to get a specific version. 7 rake rails:freeze:edge 8 # Add Capistrano configuration file 9 capify . 10 # Add Mongrel cluster configuration file 11 sudo mongrel_rails cluster::configure -e production \ 12 --user mongrel --group mongrel \ 13 -c /var/www/project-xxx/current \ 14 -a 127.0.0.1 \ 15 -p 8000 \ 16 -N 3 17 # Create a Mercurial repository 18 hg init 19 # Add project to repository 20 hg commit -A --message "Project started" 21 # Push changes to a remote repository 22 hg push ssh://user@ip:port//var/mercurial/xxx
Cloning is done with hg clone:
1 hg clone ssh://user@ip:port//var/mercurial/xxx
Display the change log (revision history) for a Mercurial repository
Use the following command to print a list of changes (revision history) for a Mercurial repository:
1 $ hg log
The output looks like this:
1 changeset: 35:5a17500addb5 2 tag: tip 3 user: christian@localhost 4 date: Fri Jun 29 23:33:59 2007 +0300 5 summary: Changed mongrel_cluster configuration 6 7 changeset: 34:a73ee17923fe 8 user: christian@localhost 9 date: Fri Jun 29 23:28:36 2007 +0300 10 summary: Fixed bugs.
In the example there are two revisions 35 and 34. Use the following command to display the details for revision 34:
1 $ hg log -p -r34
The output is a unified diff for the changeset and looks like this:
1 changeset: 34:a73ee17923fe 2 user: christian@localhost 3 date: Fri Jun 29 23:28:36 2007 +0300 4 summary: Fixed bugs. 5 6 diff -r 4c44552841af -r 4e57a76f51d9 lib/daemons/deleted_unused_tags.rb 7 --- a/lib/daemons/deleted_unused_tags.rb Sat Jun 23 23:58:38 2007 +0300 8 +++ b/lib/daemons/deleted_unused_tags.rb Sun Jun 24 00:03:43 2007 +0300 9 @@ -11,10 +11,7 @@ end 10 end
Recording a macro in vim
Vim is a powerful text editor. All powerful text editors support some kind of macro’s. Here’s how vim does it.
1 qa - start recording a macro into register 'a' 2 q - stop recording
Running the macro.
1 @a - run the macro in register 'a' 2 @@ - repeat the last macro that was run 3 10@a - run the macro in register 'a' ten times
Delete messages containing a keyword in mutt
Bulk operations in mutt, a console based email client, are easy. Here’s how to delete messages containing the keyword ‘Newsletter’.
1 T 2 Newsletter 3 ; 4 d 5 $T – asks which messages you want to tag and you reply with ‘Newsletter’.
; – asks which action you want to run on the tagged messages.
d – tells that the action you want is delete.
$ – synchronizes the view with the underlying persistence layer.