Saturday, February 21, 2009

Mounting an encrypted SDHC card as /home on Eee PC w/ Fedora

Setting up:

cryptsetup -c aes-cbc-plain luksFormat /dev/sdb1
cryptsetup luksOpen /dev/sdb1 ansilva
mkfs.ext3 /dev/mapper/ansilva
mkdir -p /home/ext/ansilva/
mount /dev/mapper/ansilva /home/ext/ansilva/

Modify /etc/fstab:

/dev/mapper/ansilva /home/ext/ansilva ext3 noauto,user 0 0

Create /usr/loca/bin/luksOpen shell script:

#!/bin/bash
cryptsetup luksOpen /dev/sdb1 ansilva
mount /dev/mapper/ansilva /home/ext/ansilva

Modify /etc/rc.local:

/usr/local/bin/luksOpen

Note 0: Deactivate the graphical boot from /etc/grub.conf so you can enter the passphrase for the encrypted file system.

Note 1: I wish I could have just gotten it to work automatically with /etc/fstab, but it seems that is a known bug in Fedora.

Monday, February 16, 2009

Apache's mod_rewrite on a specific URL parameter

The trick is to match the parameter on the QUERY_STRING variable, like this:


RewriteCond %{QUERY_STRING} ^param1=value1$
RewriteRule ^/some_script.php(.*) http://www.someotherlocation.com/another_script.php$1 [R=301,L]

Wednesday, February 11, 2009

Another handy vim shortcut

I learned this one just now...

Say you have the following text:

users:
name1, name2, name3, name4, name5, name6, name7, name8, name9, name10.

admins:
name11

And you want to move 'name5,' under admin.

Put your cursor on the n of 'name5', and use the following key sequence:


df,


That will delete forward everything up to the first comma it encounters.

Then, put your cursor under 'admins:' and hit:


p


For pasting.