Posts

Showing posts from July, 2009

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