Archive for December 2009
23
remove the first N characters from each line of output (bash)
No comments · Posted by admin in one-liners
If you want to remove the first, let’s say, 27 characters from each line of output, you would:
$ some command|sed 's/^.\{27\}//'
bash · regular expressions · sed · shell
22
clone partition table from one hard drive to another (one step)
No comments · Posted by admin in one-liners
wodim cdimage.iso
Does life get much easier? Read up about wodim for an understanding of its origins in relation to the older `cdrecord` utility
2
convert vdi to vmdk (virtualbox hard disk conversion to vmware hard disk format)
No comments · Posted by admin in code
Convert vdi to vmdk (virtualbox hard disk conversion to vmware hard disk format)
VBoxManage internalcommands converttoraw winxp.vdi winxp.raw && qemu-img convert -O vmdk winxp.raw winxp.vmdk && rm winxp.raw
Converts a .vdi file to a .vmdk file for use in a vmware virtual machine. The benefit: using this method actually works. There are others out there that claim to give you a working .vmdk by simply using the qemu-img command alone. Doing that only results in pain for you because the .vmdk file will be created with no errors, but it won’t boot either.
Be advised that these conversions are very disk-intensive by nature; you are probably dealing with disk images several gigabytes in size.
Once finished, the process of using the new .vmdk file is left as an exercise to the reader.
qemu · vboxmanage · virtualbox · vmdk · vmware
2
Easiest commandline search and replace that I know
No comments · Posted by admin in code, one-liners
perl -pi -e 's/$findstr/$replacestr/g' file1 [file2, file3...]
It does not get much better than that. You get the benefit of Perl’s superior regex engine (sed is nice but it just can’t compare), and oooooooo baby it’s fast! Perl was made to process text!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | :set nocompatible :filetype plugin indent on :syntax enable :set background=dark :set tabstop=3 :set shiftwidth=3 :set softtabstop=3 :set ignorecase :set expandtab :set modeline :set ruler :set showmatch :set nohlsearch :nnoremap <f5> :set invpaste paste?<cr> :set pastetoggle=<f5> :let perl_fold=1 :set foldmethod=syntax :set cursorline :set number :set backspace=eol,indent,start :autocmd BufWritePre * :%s/\s\+$//e :autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif " vim: set ft=vim : |
- updated Fri Jan 15 05:26:47 CST 2010 (becuz it just keeps getting more and more awesome)
1 2 3 | gpg --export-options export-local-sigs,export-attributes,export-sensitive-revkeys --export-secret-keys --armor > seckey.asc gpg --export-options export-local-sigs,export-attributes,export-sensitive-revkeys --export --armor > pubkey.asc gpg --export-ownertrust --armor > ownertrust.asc |
2
Run Trac without Apache, and include basic auth support
No comments · Posted by admin in code
/usr/bin/sudo -u www-data /usr/bin/tracd -p 80 -b $HOST -s -d --basic-auth='*',/usr/share/trac/.htpasswd,/usr/share/trac /usr/share/trac
…then set up rinetd to forward port 80 to port 8080 (you’ll have to install rinetd first; the configuration file for rinetd is very straightforward and doesn’t really need any explanation here)
1 2 3 | SELECT column_name FROM information_schema.`COLUMNS` COLUMNS WHERE table_name = 'TABLE_NAME'; |
2
Nginx fastcgi configuration example for a Perl Catalyst Application Server
No comments · Posted by admin in code, configs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | server {
listen 80;
server_name YOURDOMAIN;
access_log /var/log/nginx/access.log;
location / {
fastcgi_pass unix:/PATH/TO/YOUR/CATALYST_APP/fastcgi.socket;
include fastcgi_params;
}
location /static {
root /PATH/TO/YOUR/CATALYST_APP/root;
}
}
# LAST STEP: START YOUR CATALYST APP LIKE THIS FROM AN INIT SCRIPT OR IN A SCREEN SESSION:
# $ sudo -u www-data /PATH/TO/YOUR/CATALYST_APP/script/MYAPP_fastcgi.pl -n 10 -l fastcgi.socket -e 2>&1 |

