vi $(grep -rIl '' .)
Thursday, October 13, 2011
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'.
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.
]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.
Tuesday, June 7, 2011
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:
I'm aware regex email searching is actually more complex than this, but this regex worked well in this instance.
grep -srhw --exclude=*.{jp g,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.
Tuesday, March 8, 2011
Wednesday, March 2, 2011
jailkit
How to lock down a user with basic shell/editors/ssh access to a single subdirectory (Ubuntu 10.04).
#Install wget http://olivier.sessink.nl/jailkit/jailkit-2.13.tar.gz tar zxf jailkit* cd jailkit-2.13 ./debian/rules binary cd .. dpkg -i jailkit_2.13-1_*.deb rm -rf jailkit-2.13* #Setup 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-
How to remove the "Empty Text" text from a view-
$view->display['<display_id>']->handler->options['empty'] = '';
Sunday, February 20, 2011
Adding an email form to a Drupal View
I recently needed to add a form to the top of a view. Never having to do that before, I dove into the world of Views handlers (of which, there are way too many). I chose-
At this stage, you receive a view object right before it is rendered on the screen. However, this applies to all views, so I needed to specify the specific view/display. Selecting the view was easy-
However, I struggled on selecting just the display I wanted to affect. After lots of googling, I found the answer-
After that, it was a matter of setting-
equal to my form. All done!
Given my initial impression of Views, the object and handlers could really use some simplification. However, I'm sure there's a reason for all of it that I'm just not aware of yet (please feel free to drop some knowledge in the comments).
hook_views_pre_render(&$view)
At this stage, you receive a view object right before it is rendered on the screen. However, this applies to all views, so I needed to specify the specific view/display. Selecting the view was easy-
if ($view->vid == %d) * %d == the required view id
However, I struggled on selecting just the display I wanted to affect. After lots of googling, I found the answer-
if ($view->vid == %d && $view->current_display == %s) * %s == page_1, page_2, block_1, etc
After that, it was a matter of setting-
$view->attachment_before
equal to my form. All done!
Given my initial impression of Views, the object and handlers could really use some simplification. However, I'm sure there's a reason for all of it that I'm just not aware of yet (please feel free to drop some knowledge in the comments).
Friday, February 11, 2011
pbcopy/pbpaste
Just found this awesome piece of functionality in OS X. From terminal, pipe anything out that would typically go to stdout to pbcopy, and *bam* its in your clipboard! Have something already in clipboard? Type 'pbpaste' in terminal and there you have it!
example: cat file.txt | pbcopy
Work / Life
March 11th will be my last day at Florida Hospital. Technically my last working day will be the 4th, but I plan on going to DrupalCon that last week. Why am I leaving? Not because I dislike my current position at all, but a solid offer came my way in the form of a lead development position at Rise. Its an opportunity to build up a (much) smaller team than I'm used to (16000 employees at FH, 8 at Rise) and try my hand at leading. Its a little nerve racking, but I believe I'm up for the challenge.
Employment begins full-time at Rise on March 21st, although I've already taken on technical lead for two projects, and am actively developing on another. I've committed to an extra 10-12 hours of time per week leading up to my employment to make sure deadlines are met. Also, there's a need for a re-work of Rise's development/staging/vcs environment, so I've taken on that challenge as well. In tandem with that, I'm also working toward wrapping up existing projects at FH, as well as handing off my current responsibilities to my co-workers.
</work>
<life>
Over the last two weeks, I've become to realize how much of a challenge my current situation is. Between two jobs and finishing up outstanding side jobs, my work/life needle has been buried deep into the former. I have a beautiful wife, great family and friends, but hardly any time to see them. Even when I get those opportunities, its easy for me to drift back into what daemons still need to be set up on a new server, security, refactoring a class, Drupal theming, version control methodologies, books I haven't read, movies I haven't watched, articles in my Google Reader queue...
Its all quite overwhelming.
To compound this busy-ness, as my wife can attest, I have a terrible memory. She has an uncanny ability to remember minute social details (both in the future and past) that I, unless aforementioned event is in my calendar, cannot recall without some sort of cue. This leads to me forgetting simple day-to-day necessities and double-booking events. To combat this issue, I now fully rely on my calendar before committing to anything... which has helped a lot, but makes me feel dependent.
Now, I don't have an ultimate epiphany or really any concrete direction for this post, Its simply therapeutic to see this on screen (and helps with my new goal of blogging). I'm lucky to have a wife who invests in our relationship and helps remind me that work shouldn't be all-consuming. I love her for her support and focus on the lighter side of life (vacations, namely :) ). She truly is the reason why I'm able to pull back from the developer's tendency to completely get lost in work, and move the work/life needle more to the center where it belongs.
Employment begins full-time at Rise on March 21st, although I've already taken on technical lead for two projects, and am actively developing on another. I've committed to an extra 10-12 hours of time per week leading up to my employment to make sure deadlines are met. Also, there's a need for a re-work of Rise's development/staging/vcs environment, so I've taken on that challenge as well. In tandem with that, I'm also working toward wrapping up existing projects at FH, as well as handing off my current responsibilities to my co-workers.
</work>
<life>
Over the last two weeks, I've become to realize how much of a challenge my current situation is. Between two jobs and finishing up outstanding side jobs, my work/life needle has been buried deep into the former. I have a beautiful wife, great family and friends, but hardly any time to see them. Even when I get those opportunities, its easy for me to drift back into what daemons still need to be set up on a new server, security, refactoring a class, Drupal theming, version control methodologies, books I haven't read, movies I haven't watched, articles in my Google Reader queue...
Its all quite overwhelming.
To compound this busy-ness, as my wife can attest, I have a terrible memory. She has an uncanny ability to remember minute social details (both in the future and past) that I, unless aforementioned event is in my calendar, cannot recall without some sort of cue. This leads to me forgetting simple day-to-day necessities and double-booking events. To combat this issue, I now fully rely on my calendar before committing to anything... which has helped a lot, but makes me feel dependent.
Now, I don't have an ultimate epiphany or really any concrete direction for this post, Its simply therapeutic to see this on screen (and helps with my new goal of blogging). I'm lucky to have a wife who invests in our relationship and helps remind me that work shouldn't be all-consuming. I love her for her support and focus on the lighter side of life (vacations, namely :) ). She truly is the reason why I'm able to pull back from the developer's tendency to completely get lost in work, and move the work/life needle more to the center where it belongs.
Thursday, February 10, 2011
IP Tables
# Allow established connections to communicate back to the server
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# Open SSH, HTTP, HTTPS
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# Drop all other packets
iptables -A INPUT -j DROP
# Accept loopback
iptables -I INPUT 1 -i lo -j ACCEPT
# Log all failed attempts (if more than 5 successive attempts are made)
iptables -I INPUT 5 -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
# List all iptables in the chain
iptables -L -v
# Save iptables
iptables-save -c > /etc/iptables.rules
# Edit network interfaces to incorporate iptables
vi /etc/network/interfaces
iface eth0 inet dhcp
pre-up iptables-restore < /etc/iptables.rules
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# Open SSH, HTTP, HTTPS
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# Drop all other packets
iptables -A INPUT -j DROP
# Accept loopback
iptables -I INPUT 1 -i lo -j ACCEPT
# Log all failed attempts (if more than 5 successive attempts are made)
iptables -I INPUT 5 -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
# List all iptables in the chain
iptables -L -v
# Save iptables
iptables-save -c > /etc/iptables.rules
# Edit network interfaces to incorporate iptables
vi /etc/network/interfaces
iface eth0 inet dhcp
pre-up iptables-restore < /etc/iptables.rules
Subscribe to:
Posts (Atom)