Showing posts from September, 2009

mysql get first and last day of the month

mysql get first and last day of the month mysql> select SUBDATE('2009-08-20',DAYOFMONTH('2009-08-20')-1),DAYOFMONTH('2009-08-20'),LAST_DAY('2009-08-20') from dual; +--------------------------------------------------+--------------------------+------------------------+ | SUBDATE('2009-08-20',DAYOFMONTH('2009-08-20')-1) | DAYOFMONTH('2009-08-20') | LAST_DAY('2009-08-20') | +--------------------------------------------------+--------------------------+------------------------+ | 2009-08-01 | 20 | 2009-08-31 | +--------------------------------------------------+--------------------------+------------------------+ 1 row in set (0.00 sec)

mysql get first day of the month

This will return the first day of the month '2009-08-01' in mysql select SUBDATE('2009-08-31',DAYOFMONTH('2009-08-31')-1) from dual;

perl test if directory exists

In perl to test if a directory exists use -d "somedir" example: if(-d "/home/username") { print "User directory exists\n"; }

Ten most common mistakes in advertising

10 Most Common Mistakes in Online Advertising This is interesting

lucent in tenebris

Apparently the Morin family motto. "lucent in tenebris" which is latin for "light in darkness"

test if variable exists in ruby

Testing if a variable exists in ruby is pretty easy. irb(main):001:0> defined? variablename This will return if it's defined but not just variables but a few things "local-variable" "global-variable" nil # (undefined) "method" "super" "yield"

Interesting bash loop snippet

for r in `git rev-list master...master-fubar --since="8:00" --before="12:00" --no-merges`; do git revert --no-edit -s $r; done

Hadoop pid file location and file name

The default pid file location for a hadoop cluster as of 19.1 and 19.2, might also be the same for earlier versions of hadoop /tmp/hadoop-[USERNAME]-[NODETYPE].pid I usually run hadoop as root so here is an example of the default pid file for a datanode /tmp/ NODETYPES namenode datanode tasktracker