Wednesday, September 21, 2011

VIM Folding Fun

zf{motion} or {Visual}zf :Operator to create a fold.
zf'a : fold to mark
zF :Create a fold for N lines.
zd :Delete one fold at the cursor.
zD :Delete folds recursively at the cursor.
zE :Eliminate all folds in the window.
zo :Open one fold.
zO :Open all folds recursively.
zc :Close one fold.
zC :Close all folds recursively.
za :When on a closed fold: open it.and vice-versa.
zA :When on a closed fold: open it recursively.and vice-versa.
zR :Open all folds.
zM :Close all folds:
zn :Fold none: reset 'foldenable'. All folds will be open.
zN :Fold normal: set 'foldenable'. All folds will be as they were before.
zi :Invert 'foldenable'.
[z :Move to the start of the current open fold.
]z :Move to the end of the current open fold.
zj :Move downwards. to the start of the next fold.
zk :Move upwards to the end of the previous fold.

Friday, April 15, 2011

Grepping for email addresses

I needed to make sure we didn't have any test emails in use on a recent project. This came in handy:

grep -srhw --exclude=*.{jpg,jpeg,gif,png} "[[:alnum:]]\+@[[:alnum:]]\+" .

I'm aware regex email searching is actually more complex than this, but this regex worked well in this instance.

Wednesday, March 2, 2011


How to lock down a user with basic shell/editors/ssh access to a single subdirectory (Ubuntu 10.04).

tar zxf jailkit*
cd jailkit-2.13
./debian/rules binary
cd ..
dpkg -i jailkit_2.13-1_*.deb
rm -rf jailkit-2.13*

mkdir /jail
chown root:root /jail
jk_init -v /jail basicshell
jk_init -v /jail editors
jk_init -v /jail ssh

#Add user
adduser <user>
jk_jailuser -m -j /jail <user>

#Bind home dir
mkdir -p /jail/home/<user>
chown <user>:<user> /jail/home/<user>
mount -o bind /jail/home/<user> /path/to/dir/

Tuesday, February 22, 2011

Remove "Empty Text" from a View

Really Views? Why do you hate me so??

How to remove the "Empty Text" text from a view-

$view->display['<display_id>']->handler->options['empty'] = '';