Posts

Showing posts from 2009

How to start a single hadoop tasktracker

/usr/local/hadoop/bin/hadoop-daemon.sh --config /usr/local/hadoop/bin/../conf start tasktracker

How to start a single hadoop datanode

/usr/local/hadoop/bin/hadoop-daemon.sh --config /usr/local/hadoop/bin/../conf start datanode

Excel short cut to edit the active cell in a mac

Control U will let you edit the active excel in a mac

Learning Software Maintenance from old continuous systems

Great software article promoting continuous software maintenance model which was invented in some systems over 40 years ago. You Don't Know Jack About Software Maintenance We can learn a thing or two for modern software development

Apple App Store Process is Frustrating

I have had lot's of frustration with the App Store process. Namely with the feed back on rejections being so poor. Developers leaving the Apple App Store . I am not leaving but it is a crappy position to put developers in whom put in their own hard time into producing something that might be rejected or floating in limbo for ever.

Programming words of wisdom

1. Either leave the existing brace style the hell alone and live with it, or completely re-write the code. Going the middle road leaves two unhappy parties, leaving it alone or replacing it leaves just one. And while you should err on the side of just living with what’s already there, you shouldn’t be shy about cleaning up a train wreck. 2. Good programs do not contain spelling errors or have grammatical mistakes. I think this is probably a result of fractal attention to detail; in great programs things are correct at all levels, down to the periods at the ends of sentences in comments. “Aw, c’mon! You’re kidding!” You might think that nit-picking like this is beneath you, whereupon I will start pointing out errors in your code. It was embarrassing the first couple times this happened to me. 3. Crack open your current project. Now, delete as much stuff as you can and still have it work. Done? Okay, now toss out more, because I know that your first pass was too timid. Pretend that you’r

Bash how to write a file using cat and multi line string

Thought this was a cool example cat >hello.go <<EOF package main import "fmt" func main() { fmt.Printf("hello, world\n") } EOF

Bash Single Line For Loop Example

Here is a example of a for each loop in a single line in Bash # for hi in 1 2 ; do echo $hi; echo "wow"; done; 1 wow 2 wow #

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/hadoop-root-datanode.pid NODETYPES namenode datanode tasktracker

perl convert a string to a number

All you have to do is call int to change a string to a int my $someint = int($somestring);

python print standard error

Printing is very simple to the standard error sys.stderr.write('Printing to the stderr')

vim insert mode

To get into vim insert mode Just type the letter i This will put you in insert mode when you are in command mode. By default your in command mode when you enter vim. To get into command mode just type the escape key ESC

python else if statement

Is actually a elif statement. Here is an example below python else if statement >>> x = int(raw_input("Please enter a number: ")) >>> if x < 0: ... x = 0 ... print 'Negative changed to zero' ... elif x == 0: ... print 'Zero' ... elif x == 1: ... print 'Single' ... else: ... print 'More'

python elsif statement

python else if statement >>> x = int(raw_input("Please enter a number: ")) >>> if x < 0: ... x = 0 ... print 'Negative changed to zero' ... elif x == 0: ... print 'Zero' ... elif x == 1: ... print 'Single' ... else: ... print 'More'

vim how to highlight

vim how to highlight You can turn on syntax highlighting by typing: >:syntax enable

vim how to go to the end of file

vim how to go to the end of file. Just type: > g Where is is meant to say you hold down the shift key while pressing g

vim how to quit

vim how to quit. That's another easy one. Just type: >:q To quit without saving type: >:q! To save then quit type: >:wq

vim how to save

Vim how to save a file easy. Just type ESC key (this put you in command mode) If you open a file using something like vim SOMEFILENAME Then type >:w If it's a new file just type >:w SOMEFILENAME

Vim how to open a file to edit

All you need to do is type the vim command :edit or you can use the shortcut :e will open the file for editing.

How to escape single quotes bash

Just use my web page that I setup to escape single quotes in bash http://www.stevemorin.com/utils/bashEscape.html

Open Source Message Queues AMQP

AMQP http://www.amqp.org http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol

Downtown San Francisco Beginner Yoga

I have started beginner Yoga in downtown San Francisco and love it. I go to http://www.itsyoga.net 307 5th Street Suite A San Francisco, CA 94107 (415) 543-1970 If your a beginner and want a great class you should come. Steve

python for loop example

Python for loop >>> for i in range(10): ... print i ... 0 1 2 3 4 5 6 7 8 9 >>>

Programming Perl Pages

I put programming perls in google by accident and this link came up http://homepages.cwi.nl/~tromp/pearls.html Have a few compact and cool programs in particular a cool prime sieve. Steve

Hadoop stop one node in a cluster

If you want to stop one node in a hadoop cluster run the following two commands. /usr/local/hadoop/bin/hadoop-daemon.sh --config /usr/local/hadoop/bin/../conf stop datanode /usr/local/hadoop/bin/hadoop-daemon.sh --config /usr/local/hadoop/bin/../conf stop tasktracker

Hadoop stop a single tasktracker node how to.

Here is how to stop a single tasktracker node in a hadoop cluster. /usr/local/hadoop/bin/hadoop-daemon.sh --config /usr/local/hadoop/bin/../conf stop tasktracker

Example how to stop a single hadoop datanode

The normal command you are shown shutsdown the entire cluster. To shutdown a single datanode for maintenance run the following command. /usr/local/hadoop/bin/hadoop-daemon.sh --config /usr/local/hadoop/bin/../conf stop datanode

test if variable exists in lisp

test if variable exists in perl Just use the boundp function (setq x 1) => 1 (boundp 'x) => true

test if variable exists in perl

In most cases just use the perl function defined if(defined $somevar) { print "This variable exists\n"; }

Ad Bright working on blogger

This article describes it best on how to get Ad Bright working on Blogger http://www.mydigitallife.info/2007/09/21/trick-to-add-adsense-adbrite-and-other-javascript-ad-code-directly-to-blogger-html-template/ < – < > – > Above two is enough to make Google AdSense works in Blogger template. For other scripts, such as AdBrite ad code, you will need to replace more characters such as those listed below. & = & ” = "

HadoopDb

Here is a great article about scalable analytics and a hybrid system called HadoopDB http://dbmsmusings.blogspot.com/2009/07/announcing-release-of-hadoopdb-longer.html HadoopDB can be found at http://db.cs.yale.edu/hadoopdb/hadoopdb.html Footnote mentions of open source column-store database systems such as MonetDB and Infobright

Rsync - a great tool

If you haven't used rsync yet you should. It's a great tool for mirroring http://www.samba.org/rsync/

Mac IPSec VPN Software

This is a great Opensource Mac IPSec VPN Software package, the commercial great is VPNTracker http://www.lobotomo.com/products/IPSecuritas/index.html

bash not operator

if [ ! -d $directory ]; then echo "Directory does not exist" else echo "Directory does exist" fi

bash else if

if [ -d $directory ]; then echo "Directory exists" elif [ -d $directory2 ]; then echo "Directory2 exists" else echo "Directory does not exists" fi

bash test if directory exists

Here is how to tell if a directory exists in bash. if [ -d 'somedirectory' ]; then #some bash commands fi

perl getopts example

http://perldoc.perl.org/Getopt/Long.html I love perl's getopt example, it's very easy to use and to the point. Here is the standard example from the documentation use Getopt::Long; my $data = "file.dat"; my $length = 24; my $verbose; $result = GetOptions ("length=i" => \$length, # numeric "file=s" => \$data, # string "verbose" => \$verbose); # flag All you need to do now to check if your variable is is set and use it Example: if(! defined $data) { die "Throwing error because required field isn't set."; }

How to vim current line to end of file command

To run a command in vim from the current line till the end of the file you do the following .,$d .,${command here} .,$y

Vim how to do command on current line plus 1 2 etc lines

Vim how to do command on current line plus 1 2 etc lines .,+1s/^/text/ #command on one line .,+2dd #command on two lines .,+3>> #command on three lines So the syntax is .,+{number of lines}{vim command}

Php How to set the selected option from presence of a variable

How to set the selected option from presence of a variable is this simple. <option value="somevalue" <?= ? array_key_exists('variablename', $_GET) "selected" : "" ?>>Display value </option>

How to test if php get variable is set

Testing to see if a php get variable is set is a very easy thing to do. All you need is this one line. array_key_exists('nameofgetvariable', $_GET)

How to set the default option on the html tag

To add the default option to a html pull down option.

vim how to add text to the beginning of every line

In vim to add text to the beginning of every line is easy. vim filename :%s/^/texttoadd/ Be careful with the texttoadd because you might have to escape certain characters.

How to run a remote mysql command

If you have a mysql client install you can run commands from the command line on a remote mysql server running the following command. Remember you can use single quotes safely between the double quotes. mysql -uusername -ppassword -h192.168.1.1 dbname -e "select * from dual ;" ;

How to add a line to beginning of a file

Run the following command This is a perl one liner that will append text to the beginning of a file. PS It edits the file in place so please backup your file first before running. perl -i -ple 'print q{PUTYOURTEXTHERE} if $. == 1; close ARGV if eof' myfilename

how to count dirs with perl one liner

This example will first cd into the directory that you want to start searching from. It will descend into each sub directory counting the number of entries(files or dirs) and print it out to the command line. The last step sort the output. cd /mydir; perl -MFile::Find -e 'find({wanted=>sub {},no_chdir=>1,postprocess=>sub {my $wc = `ls $File::Find::dir | wc -l`;chomp($wc);print "$wc\t$File::Find::dir\n"; }}, ("."));' | sort -n

How to make a lisp comment

The semi colon aka -> ; ; is the lisp comment character example: (print "Hello World\n") ; this prints the standard Hello World
Just running a test! showhide Real's HowTo

Textmate Ruby Macro Remove Blank Lines

Textmate Ruby Macro Remove Blank Lines #!/usr/bin/env ruby -wKU STDIN.readlines.each {|e| print e unless e =~ /^\n/} #Set Save "Nothing" #Set Input "Selected Text" or "Character" # and #Set Output "Replace Selected Text"

Textmate Ruby Macro Comma Separated List to Line

Textmate Ruby Macro Comma Separated List to Line #!/usr/bin/env ruby -wKU STDIN.read.split(",").each {|e| print e+"\n"} #Set Save "Nothing" #Set Input "Selected Text" or "Character" # and #Set Output "Replace Selected Text"

Textmate Ruby Macro Lines to Comma Separated List

Lines to Comma Separated List #!/usr/bin/env ruby -wKU STDIN.readlines.each {|e| print e.gsub(/\n/,",")} print "\n" #Set Save "Nothing" #Set Input "Selected Text" or "Character" # and #Set Output "Replace Selected Text"
Looks useful thanks David Thomas Original Link HANDY ONE-LINERS FOR RUBY November 16, 2005 compiled by David P Thomas version 1.0 Latest version of this file can be found at: http://www.fepus.net/ruby1line.txt Last Updated: Wed Nov 16 08:35:02 CST 2005 FILE SPACING: # double space a file $ ruby -pe 'puts' < file.txt # triple space a file $ ruby -pe '2.times {puts}' < file.txt # undo double-spacing (w/ and w/o whitespace in lines) $ ruby -lne 'BEGIN{$/="\n\n"}; puts $_' < file.txt $ ruby -ne 'BEGIN{$/="\n\n"}; puts $_.chomp' < file.txt $ ruby -e 'puts STDIN.readlines.to_s.gsub(/\n\n/, "\n")' < file.txt NUMBERING: # number each line of a file (left justified). $ ruby -ne 'printf("%-6s%s", $., $_)' < file.txt # number each line of a file (right justified). $ ruby -ne 'printf("%6s%s", $., $_)' < fi

Vi paging up and paging down

In vi to page up and down type Ctrl-b aka (^b) Ctrl-f aka (^f)

Vi copy characters

Copying characters in vi #yl 2yl is copy/yank 2 characters from current position to the right.

A Life Time of True Love

Hopefully we all could be so luck, to have a life time of true love. Love's first blush fading? Lost that loving feeling? Love is not all around? Scientists have used brain scans to study how long love lasts between couples. Scientists have used brain scans to study how long love lasts between couples. Sick of cliches? Take heart, scientists have discovered that people can have a love that lasts a lifetime. Using brain scans, researchers at Stony Brook University in New York have discovered a small number of couples respond with as much passion after 20 years together as most people only do during the early throes of romance, Britain's Sunday Times newspaper reported. The researchers scanned the brains of couples together for 20 years and compared them with results from new lovers, the Sunday Times said. About 10 percent of the mature couples had the same chemical reactions when shown photographs of their loved ones as those just starting out. Previous research has suggested th