<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Bin-Blog</title>
	
	<link>http://www.bin-co.com/blog</link>
	<description>Learn about the latest in Web Development - as soon as I do.</description>
	<pubDate>Mon, 12 May 2008 18:02:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/bin-blog" type="application/rss+xml" /><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site, subject to copyright and fair use.</feedburner:browserFriendly><item>
		<title>Hello Script for bash</title>
		<link>http://feeds.feedburner.com/~r/bin-blog/~3/288851573/</link>
		<comments>http://www.bin-co.com/blog/2008/05/hello-script-for-bash/#comments</comments>
		<pubDate>Mon, 12 May 2008 18:02:25 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[bash]]></category>

		<category><![CDATA[hello]]></category>

		<category><![CDATA[script]]></category>

		<category><![CDATA[scripting]]></category>

		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=107</guid>
		<description><![CDATA[Hello Script series for Bash. &#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language.
bash
bash is the most commonly used shell in Linux. That makes the bash scripting language the most popular shell scripting [...]]]></description>
			<content:encoded><![CDATA[<p class="intro"><a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script series</a> for Bash. <strong>&#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language.</p>
<h2>bash</h2>
<p><a href="http://www.gnu.org/software/bash/">bash</a> is the most commonly used shell in Linux. That makes the bash scripting language the most popular shell scripting language. OK, maybe after batch. But then again, bash is much more powerful than batch(DOS scripting language). If want to learn bash, I will recommend this tutorial - <a href="http://tldp.org/LDP/abs/html/">Advanced Bash Scripting</a></p>
<p>Officially, <a href="http://lindesk.com/2008/05/shell-script-language-use-perl-not-bash/">I hate bash</a>. I use perl or other similar high level language to create shell script. I use bash only for the <a href="http://binnyva.blogspot.com/2007/03/using-twitter-part-1-command-line.html">simplest scripts</a>. But even I admit that bash has its uses. So, here is the hello script for bash&#8230;</p>
<h2>Hello Script</h2>
<pre><code class="bash">
#!/usr/sh

# Printing(IO)
echo "Hello World"

# Variables, concatenation
name='Binny'
year=2008
echo "Hello, " $name " - welcome to " $year

#If,else conditions
if [ $year -gt 2008 ]; then
	echo &#8220;Welcome to the future - yes, we have flying cars!&#8221;

elif [ $year -lt 2008 ]; then
	echo &#8220;The past - please don&#8217;t change anything. Don&#8217;t step on any butterflies. And for the sake of all that&#8217;s good and holy, stay away from your parents!&#8221;

else
	echo &#8220;Anything wrong with your time machine? You have not gone anywhere, kiddo.&#8221;
fi

# If you are using anything after this, consider using a high level language.
# For loop
for i in 1 2 3
do
	echo $i &#8220;) Hi there!&#8221;
done

#Numerical Array, foreach
rules[0]=&#8221;Do no harm&#8221;
rules[1]=&#8221;Obey&#8221;
rules[2]=&#8221;Continue Living&#8221;

for ((i=0; i &lt; 3; i++))
do
	echo &#8220;Rule&#8221; `expr $i + 1` &#8220;:&#8221; ${rules[$i]}
done

#A While Demo
keys=(hello foo lorem)

i=0
while [ $i -lt 3 ]
do
	echo ${keys[$i]}
	i=`expr $i + 1`
done

# Function, argument, return, call
hello () {
	myname=$1  #First argument.
	echo &#8220;Hello&#8221; $myname
}
hello &#8220;Binny&#8221;

# File IO
# File reading
contents=`cat Hello.sh` #For some reason, I&#8217;m losing all the \n&#8217;s in the file.
echo &#8220;Hello has `echo $contents|wc -m` chars&#8221; # Or wc -m Hello.sh

# Writing to a file
echo &#8220;Hello World from shell script&#8221; &gt; /tmp/hello.txt

# Command Executing
ls

# Regular Expressions
string=&#8221;Hello World&#8221;
evil=`echo $string | grep &#8216;^Hell&#8217;`
if [ "$evil" != "" ]; then
	echo &#8220;Yup - its evil&#8221;
fi
echo &#8220;Hello World&#8221; | sed -e &#8217;s/l//g&#8217; #Will return Heo Word

# http://tldp.org/LDP/abs/html/
</code></pre>
<p>And, by the way, this will work only in Linux - or if you installed cygwin in your Windows system. Use <code>sh &lt;File_Name&gt;</code> to execute the above code.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/bin-blog?a=4Jcu9h"><img src="http://feeds.feedburner.com/~f/bin-blog?i=4Jcu9h" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=AYMPgh"><img src="http://feeds.feedburner.com/~f/bin-blog?i=AYMPgh" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=LaSuLH"><img src="http://feeds.feedburner.com/~f/bin-blog?i=LaSuLH" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bin-blog/~4/288851573" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/05/hello-script-for-bash/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.bin-co.com/blog/2008/05/hello-script-for-bash/</feedburner:origLink></item>
		<item>
		<title>URL Lister - My First Firefox Plugin</title>
		<link>http://feeds.feedburner.com/~r/bin-blog/~3/285534425/</link>
		<comments>http://www.bin-co.com/blog/2008/05/url-lister-my-first-firefox-plugin/#comments</comments>
		<pubDate>Wed, 07 May 2008 18:03:52 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
		
		<category><![CDATA[Browsers]]></category>

		<category><![CDATA[Firefox]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[download]]></category>

		<category><![CDATA[lister]]></category>

		<category><![CDATA[plugin]]></category>

		<category><![CDATA[release]]></category>

		<category><![CDATA[script]]></category>

		<category><![CDATA[tab]]></category>

		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=106</guid>
		<description><![CDATA[
I just released my first firefox plugin - URL Lister. It shows the URLs of all the open tabs in a textarea so that they can be copied easily.
Download/Install
Install URL Lister
If you have installed it, consider rating it or reviewing it at Firefox plugins sandbox. Go to the public page for URL Lister and write [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/tools/firefox/extensions/urllister/url_lister_logo.png" alt="URL Lister Logo" class="intro" align="right" /></p>
<p class="intro">I just released my first firefox plugin - <a href="http://www.bin-co.com/tools/firefox/extensions/urllister/">URL Lister</a>. It <strong class="highlight">shows the URLs of all the open tabs in a textarea so that they can be copied</strong> easily.</p>
<h2>Download/Install</h2>
<p><a href="http://www.bin-co.com/tools/firefox/extensions/urllister/urllister.xpi">Install URL Lister</a></p>
<p>If you have installed it, consider <strong class="highlight">rating it or reviewing it at Firefox plugins sandbox</strong>. Go to the <a href="https://addons.mozilla.org/en-US/firefox/addon/7192">public page for URL Lister</a> and write a review for the application. <strong class="highlight">I need reviews to promote it to the main extensions page</strong> - sandbox plugins are for registered users only.</p>
<h2>Usage</h2>
<p>Lets say you have these four tabs open&#8230;</p>
<ul>
<li><a href="http://www.openjs.com/">OpenJS - JavaScript, Opened.</a></li>
<li><a href="http://www.bin-co.com/">Bin-Co</a></li>
<li><a href="http://lindesk.com/">LinDesk</a></li>
<li><a href="http://blog.binnyva.com/">BinnyVA</a></li>
</ul>
<p>Right click any tab and click on the &#8216;URL Lister&#8230;&#8217; to open up the main dialog. You can also use &#8216;Tools &gt; URL Lister&#8217;. You will find the URLs of all the open tabs there.</p>
<p><img src="http://www.bin-co.com/tools/firefox/extensions/urllister/url_lister_screenshot.png" alt="URL Lister Screenshot" /></p>
<p>There is a drop down menu at the bottom - it has these three options&#8230;</p>
<ul>
<li>Plain Text</li>
<li>HTML Anchors</li>
<li>Linked List</li>
</ul>
<h3>Open URLs</h3>
<p>If you have a list of URLs and want to open them all, all you have to do is copy those URLs into this dialog and press OK - this will open up all the given URLs.</p>
<h2>And my thanks goes to&#8230;</h2>
<p>URL Lister is sort of a response to <a href="http://www.mattcutts.com/blog/wanted-convert-firefox-tabs-to-links/">this post</a> by Matt Cutts. I want to thank him for the idea.</p>
<p>There is another plugin with a similar function - <a href="https://addons.mozilla.org/en-US/firefox/addon/2069">Tab URL Copier</a>. I lifted some code from that plugin when creating URL Lister. Thanks.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/bin-blog?a=hMywgh"><img src="http://feeds.feedburner.com/~f/bin-blog?i=hMywgh" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=QDGxhh"><img src="http://feeds.feedburner.com/~f/bin-blog?i=QDGxhh" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=glD0OH"><img src="http://feeds.feedburner.com/~f/bin-blog?i=glD0OH" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bin-blog/~4/285534425" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/05/url-lister-my-first-firefox-plugin/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.bin-co.com/blog/2008/05/url-lister-my-first-firefox-plugin/</feedburner:origLink></item>
		<item>
		<title>Hello Script for Ruby</title>
		<link>http://feeds.feedburner.com/~r/bin-blog/~3/281595450/</link>
		<comments>http://www.bin-co.com/blog/2008/05/hello-script-for-ruby/#comments</comments>
		<pubDate>Thu, 01 May 2008 18:05:39 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
		
		<category><![CDATA[Ruby]]></category>

		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[cheatsheet]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[hello]]></category>

		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=104</guid>
		<description><![CDATA[
Hello Script is a file that contains the most commonly used elements of a programming language so that it can be used as a cheatsheet when working with that language. This Hello Script for Ruby is the sixth post in this series.
I have some experience with Ruby. I will not call myself an expert - [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.bin-co.com/blog/wp-content/uploads/2008/05/ruby_logo.gif'><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/05/ruby_logo.gif" alt="" title="Ruby Logo" width="105" height="109" align="right" class="intro size-full wp-image-105" /></a></p>
<p class="intro"><a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script</a> is a <strong class="highlight">file that contains the most commonly used elements of a programming language so that it can be used as a cheatsheet</strong> when working with that language. This Hello Script for Ruby is the sixth post in this series.</p>
<p>I have some experience with Ruby. I will not call myself an expert - but I am comfortable with Ruby. <a href="http://binnyva.blogspot.com/2005/09/learning-ruby.html">I like ruby.</a> I even have written a few <a href="http://www.bin-co.com/ruby/tk/locater/">applications</a> in it.</p>
<h2>Hello Code</h2>
<pre><code class="ruby">
#!/usr/bin/ruby

print "Hello World\n"

name = "Binny"
year = 2008
print "Hello, " + name + " - welcome to " + year.to_s + "\n"

if (year &gt; 2008) then
	print "Welcome to the future - yes, we have flying cars!"
elsif (year &lt; 2008) then
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!"
else
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo."
end
print "\n\n"

# For loop like structure
0.upto(3) { |i|
	print i.to_s + ") Hi there!\n"
}
print "\n"

# Numerical array
rules = ['Do no harm', 'Obey', 'Continue Living']
i = 0
while i&lt;rules.length do
	print &#8220;Rule &#8221; + (i+1).to_s + &#8220;: &#8221; + rules[i] + &#8220;\n&#8221;
	i = i+1
end
print &#8220;\n&#8221;

# Associated arrays
associated = {
	&#8216;hello&#8217;	=&gt;	&#8216;world&#8217;,
	&#8216;foo&#8217;	=&gt;	&#8216;bar&#8217;,
	&#8216;lorem&#8217;	=&gt;	&#8216;ipsum&#8217;
}
associated.each { |key,value|
	print key + &#8221; : &#8221; + value + &#8220;\n&#8221;
}
print &#8220;\n&#8221;

# Using Join and Split
csv_values = &#8220;hello,world,how,are,you\n&#8221;.split(&#8221;,&#8221;)
print csv_values.join(&#8221;:&#8221;)

# Function, argument, return, call
def hello(name)
	return &#8220;Hello &#8221; + name
end
hello_string = hello(&#8221;Binny&#8221;)
print &#8220;Function call returned &#8216;&#8221; + hello_string + &#8220;&#8216;\n\n&#8221;

# One for the OOP fanboys - Class, members, object and stuff.
class Movie
	public
	@name = &#8221;
	@rating = 0

	def initialize(name)
		@name = name
		self.rateMovie()
	end

	def rateMovie()
		@rating = (@name.length % 10) + 1 #IMDBs rating algorithm. True story!
	end

	def printMovieDetails()
		print &#8220;Movie : &#8221; + @name + &#8220;\n&#8221;
		print &#8220;Rating : &#8221; + &#8216;*&#8217; * @rating + &#8220;(&#8221; + @rating.to_s + &#8220;)\n\n&#8221;
	end
end
# Create the object
ncfom = Movie.new(&#8221;New Country for Old Men&#8221;) #It&#8217;s a sequel!
ncfom.printMovieDetails()

# File IO
# File reading, easy method&#8230;
file_in = File.new(&#8217;Hello.rb&#8217;, &#8216;r&#8217;)
contents = file_in.read
file_in.close
print &#8220;Hello has &#8221; + contents.length.to_s + &#8221; chars\n&#8221;

# Writing to a file
file_out = File.new(&#8217;/tmp/hello.txt&#8217;, &#8216;w&#8217;)
file_out.print &#8220;Hello World from Ruby.&#8221;
file_out.close

# Command Executing
print `ls` #Execute the command &#8216;ls&#8217; and print its output
print &#8220;\n&#8221;

# Regular Expressions
string = &#8220;Hello World&#8221;
print &#8220;Yup - its evil\n&#8221; if(/^Hell/.match(string))
print string.gsub(/l([^l])/, &#8216;\1&#8242;) #Remove an &#8216;l&#8217; from both words. Should print &#8216;Helo Word&#8217; - The second arg must be in single quotes

print &#8220;\n&#8221;

# Some special/only-in-ruby stuff&#8230;
# Using a library
require &#8220;fileutils&#8221;

#Using yield/code blocks&#8230;
def doXTimes(i)
	0.upto(i) {|count|
		yield count+1
	}
end
doXTimes(5) {|count|
	print count.to_s + &#8220;th Time\n&#8221;
}

</code></pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/bin-blog?a=FYsdKh"><img src="http://feeds.feedburner.com/~f/bin-blog?i=FYsdKh" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=aXHQSh"><img src="http://feeds.feedburner.com/~f/bin-blog?i=aXHQSh" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=qYgheH"><img src="http://feeds.feedburner.com/~f/bin-blog?i=qYgheH" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bin-blog/~4/281595450" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/05/hello-script-for-ruby/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.bin-co.com/blog/2008/05/hello-script-for-ruby/</feedburner:origLink></item>
		<item>
		<title>Hello Script for Tcl</title>
		<link>http://feeds.feedburner.com/~r/bin-blog/~3/277039704/</link>
		<comments>http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/#comments</comments>
		<pubDate>Thu, 24 Apr 2008 17:14:29 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
		
		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[hello]]></category>

		<category><![CDATA[language]]></category>

		<category><![CDATA[script]]></category>

		<category><![CDATA[tcl]]></category>

		<category><![CDATA[tk]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=103</guid>
		<description><![CDATA[
 Tcl, or Tool Command Language, will not be found in the &#8216;most popular languages&#8217; hall of fame. That is partly because of its &#8216;wierd&#8217; syntax. But those who know Tcl will tell you that Tcl is a pleasure to work with. I have a special interest in Tcl - its the language that introduced [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.bin-co.com/images/tcl.gif' alt='Tcl Logo' align="right" /></p>
<p class="intro"> <a href="http://www.tcl.tk/">Tcl, or Tool Command Language</a>, will not be found in the &#8216;most popular languages&#8217; hall of fame. That is partly because of its &#8216;wierd&#8217; syntax. But those who know Tcl will tell you that Tcl is a pleasure to work with. I have a special interest in Tcl - its the language that introduced me to GUI programming(<a href="http://www.bin-co.com/tcl/">Tcl/Tk</a>). Now, when ever I see a GUI toolkit, I <a href="http://www.bin-co.com/blog/2007/10/tk-verses-gtkand-python-verses-tcl/">compare it to Tcl</a>.</p>
<p>I have a few years experience in Tcl - I have written a very popular <a href="http://www.bin-co.com/tcl/tutorial/">Tcl/Tk Tutorial</a> and also a <a href="http://www.bin-co.com/tcl/scripts/indexer/">few</a> <a href="http://www.bin-co.com/tcl/scripts/ri/">small</a> <a href="http://www.bin-co.com/tcl/scripts/tagview/">applications</a> in Tcl. I am not using it a lot now a days because Tk apps look really bad in Linux. This problem is not present in Windows.</p>
<h3>Hello Code</h3>
<pre><code class="tcl">
#!/usr/bin/tclsh

# Printing(IO)
puts "Hello World!\n" 

# Variables, concatenation
set name 'Binny'
set year 2008
puts [concat "Hello, "  $name  " - welcome to "  $year]

#If,else conditions
if { $year &gt; 2008 } {
	 puts &#8220;Welcome to the future - yes, we have flying cars!&#8221; 

} elseif { $year &lt; 2008 }  {
	 puts &#8220;The past - please don&#8217;t change anything. Don&#8217;t step on any butterflies. And for the sake of all that&#8217;s good and holy, stay away from your parents!&#8221; 

} else {
	 puts &#8220;Anything wrong with your time machine? You have not gone anywhere, kiddo.&#8221;
}

# For loop
for { set i 0 } { $i&lt;3 } { incr i  }  {
	 puts &#8220;$i) Hi there!&#8221;
}

#Numerical Array, foreach
set rules [list "Do no harm" "Obey" "Continue Living"]

set i 0
while { $i &lt; [llength $rules] } {
	puts [concat "Rule " [expr $i+1] &#8221; : &#8221;  [lindex $rules $i]]
	incr i
}

# Associated array, while
array set associated {
	hello	&#8220;world&#8221;
	foo		&#8220;bar&#8221;
	lorem	&#8220;ipsum&#8221;
}

foreach key [array names associated] {
	 puts [concat $key " : " $associated($key)]
}

# Using Join and Split
set csv_values [split "hello,world,how,are,you\n" ","]
puts [join $csv_values ":"]

# Function, argument, return, call
proc hello { person_name } {
	return [concat "Hello, " $person_name]
}
puts [hello "Binny"]

# File IO
# File reading, easy method&#8230;
set IN [open "Hello.tcl" r]
set contents [read $IN]
close $IN
puts [concat "Hello has " [string length $contents] &#8221; chars&#8221;]

# Writing to a file
set OUT [open "/tmp/hello.txt" w]
puts $OUT &#8220;Hello World&#8221;
close $OUT

# Regular Expressions
set str &#8220;Hello World&#8221;
if { [regexp {^Hell} $str] } {
	puts &#8220;Yup, its evil&#8221;
}

puts [regsub -all {l([^l])} $str {\1}]

# Special Tcl Syntax
# Math ops
set answer [expr {3 + 2}]

# Comments
puts $answer ;# Comments in the same line as code must use ;# instead of just #

</code></pre>
<h3>Tcl/Tk Links</h3>
<ul>
<li><a href="http://www.tcl.tk/">Tcl Developer Xchange</a></li>
<li><a href="http://wiki.tcl.tk/">Tcler&#8217;s Wiki</a></li>
<li><a href="http://en.wikipedia.org/wiki/Tcl">Tcl in Wikipedia</a></li>
<li><a href="http://www.yosefk.com/blog/i-cant-believe-im-praising-tcl.html">I can’t believe I’m praising Tcl</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/bin-blog?a=05mRBSg"><img src="http://feeds.feedburner.com/~f/bin-blog?i=05mRBSg" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=tnhnszg"><img src="http://feeds.feedburner.com/~f/bin-blog?i=tnhnszg" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=2Q2rhEG"><img src="http://feeds.feedburner.com/~f/bin-blog?i=2Q2rhEG" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bin-blog/~4/277039704" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/</feedburner:origLink></item>
		<item>
		<title>Perl Hello Script</title>
		<link>http://feeds.feedburner.com/~r/bin-blog/~3/267861404/</link>
		<comments>http://www.bin-co.com/blog/2008/04/perl-hello-script/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 18:01:45 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
		
		<category><![CDATA[Perl]]></category>

		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[cheatsheet]]></category>

		<category><![CDATA[hello]]></category>

		<category><![CDATA[reference]]></category>

		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/04/perl-hello-script/</guid>
		<description><![CDATA[
This is the next installment of the Hello Script series - Hello Script for Perl. &#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language.
Introduction to Perl
For those of who are unfamiliar with perl, [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.bin-co.com/blog/wp-content/uploads/2008/04/perl.gif' alt='Perl Logo' class="intro" align="right" /></p>
<p class="intro">This is the next installment of the <a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script series</a> - Hello Script for Perl. <strong class="highlight">&#8216;Hello Script&#8217; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language.</p>
<h2>Introduction to Perl</h2>
<p>For those of who are unfamiliar with perl, here is the Wikipedia definition&#8230;</p>
<blockquote><p>Perl is a dynamic programming language created by Larry Wall and first released in 1987. Perl borrows features from a variety of other languages including C, shell scripting (sh), AWK, sed and Lisp. Perl was widely adopted for its strengths in text processing and lack of the arbitrary limitations of many scripting languages at the time.</p></blockquote>
<p>If you are interested in learning perl, I have written a <a href="http://www.bin-co.com/perl/tutorial/">Perl Tutorial</a>. And here are some more links if you are interested</p>
<ul>
<li><a href="http://www.perl.com/">Perl.com</a></li>
<li><a href="http://www.perl.org/">The Perl Directory</a></li>
<li><a href="http://www.perlmonks.org/">Perl Monks</a></li>
</ul>
<h2>Hello Script for Perl</h2>
<pre><code class="perl">
#!/usr/bin/perl
use strict;
use warnings;

# Printing(IO)
print "Hello World!\n";

# Variables, concatenation
my $name = 'Binny';
my $year = 2008;
print "Hello, " . $name . " - welcome to " . $year . "\n";

#If,else conditions
if ($year &gt; 2008) {
	print "Welcome to the future - yes, we have flying cars!";
}
elsif($year &lt; 2008) {
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!";
}
else {
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo.";
}
print "\n";

# For loop
for(my $i=0; $i&lt;3; $i++) {
	print "$i) Hi there!\n";
}

#Numerical Array, foreach
my @rules = (
	'Do no harm',
	'Obey',
	'Continue Living'
);
my $i = 1;
foreach my $rule (@rules) {
	print "Rule " . $i . " : " . $rule . "\n";
	$i++;
}

# Associated array, while
my %associated = (
	'hello'	=&gt;	'world',
	'foo'	=&gt;	'bar',
	'lorem'	=&gt;	'ipsum'
);
while(my ($key, $value) = each(%associated)) {
	print "$key: $value\n";
}

# Using Join and Split
my @csv_values = split(',', "hello,world,how,are,you\n");
print join(":", @csv_values);

# Function, argument, return, call
sub hello {
	$name = shift; #First argument.
	return "Hello " . $name;
}
print hello("Binny");

# File IO
# File reading, easy method...
open(IN,'Hello.pl') or die("Cannot open file : $!");
my @lines = &lt;IN&gt;;
close(IN);
my $contents = join('',@lines);
print "Hello has " . length($contents) . " chars\n";
# Writing to a file
open(OUT, '&gt;/tmp/hello.txt');
print OUT "Hello World";
close(OUT);

# Command Executing
print `ls`; #Execute the command 'ls' and print its output
print "\n";

# Regular Expressions
my $string = "Hello World";
print "Yup - its evil\n" if($string =~ /^Hell/);
$string =~ s/l([^l])/$1/g; #Remove an &#8216;l&#8217; from both words. Should print &#8216;Helo Word&#8217;
print $string;

print &#8220;\n\n&#8221;;
</code></pre>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/bin-blog?a=QWRRArg"><img src="http://feeds.feedburner.com/~f/bin-blog?i=QWRRArg" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=J30veSg"><img src="http://feeds.feedburner.com/~f/bin-blog?i=J30veSg" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=bZcEAhG"><img src="http://feeds.feedburner.com/~f/bin-blog?i=bZcEAhG" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bin-blog/~4/267861404" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/04/perl-hello-script/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.bin-co.com/blog/2008/04/perl-hello-script/</feedburner:origLink></item>
		<item>
		<title>Document Formats</title>
		<link>http://feeds.feedburner.com/~r/bin-blog/~3/263494014/</link>
		<comments>http://www.bin-co.com/blog/2008/04/document-formats/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 18:20:39 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
		
		<category><![CDATA[Database]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[Opinion]]></category>

		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[document]]></category>

		<category><![CDATA[format]]></category>

		<category><![CDATA[html]]></category>

		<category><![CDATA[online]]></category>

		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/04/document-formats/</guid>
		<description><![CDATA[
In FLOSS circles, March 26 is celebrated as the Document Freedom Day. 
Document Freedom Day (DFD) is a global day for document liberation. It will be a day of grassroots effort to educate the public about the importance of Free Document Formats and Open Standards in general.
This is when I realized that people actually use [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro" align="right"  src='http://www.bin-co.com/blog/wp-content/uploads/2008/04/documents.jpg' alt='Documents' /></p>
<p class="intro">In FLOSS circles, March 26 is celebrated as the <a href="http://www.documentfreedom.org/">Document Freedom Day</a>. </p>
<blockquote><p>Document Freedom Day (DFD) is a global day for document liberation. It will be a day of grassroots effort to educate the public about the importance of Free Document Formats and Open Standards in general.</p></blockquote>
<p>This is when I realized that people actually use the office packages daily. I almost never use it. According to me there are three options to store text data.</p>
<ul>
<li>Plain Text</li>
<li>HTML</li>
<li>Database</li>
</ul>
<h2>Plain Text</h2>
<p>The <strong class="highlight">simplest format</strong> there is. If there is something I should remember, I just put it in a text file and save it to the desktop. I used to use it a lot earlier - but I don&#8217;t use it much nowadays due to searchability issues. There are quite a few <a href="http://ifacethoughts.net/2007/09/27/we-need-more-txt/">advantages in using the text format</a></p>
<h2>HTML</h2>
<p>If I <strong class="highlight">need any formatting in the text, I create the document in HTML</strong>. It is easier for me to create the formatting using HTML code that using WYSIWYG Word Processors(like MS Word). I write all my blog posts in HTML - perhaps the only occasion where I need formatting.</p>
<h3>Database</h3>
<p>My favorite method to store text data is in a database. I am a web developer - so I always have a Web Server and Database server running on my system - so this system is perfect for me. </p>
<h3>Interface</h3>
<p>Remove that scared look on your face - I don&#8217;t use <a href="http://binnyva.blogspot.com/2006/08/managing-databases-with-mysql-clients.html">phpMyAdmin</a> or any Database Administration tools as the interface to save/view the data. I use my own custom scripts or WordPress.</p>
<p>The best example of this is <a href="http://txt.binnyva.com/">txt</a>. Txt is my code snippets/commands repository. You can view the full story in the <a href="http://binnyva.blogspot.com/2007/03/saving-code-snippets-part-2.html">Saving Code Snippets</a> post.</p>
<p>That&#8217;s an online example - I also have a personal wordpress blog running in my local server. I use it to record events, purchases, store receipts etc.</p>
<h3>Advantages</h3>
<dl>
<dt>Tagging</dt>
<dd><strong class="highlight">Tagging is heaven-sent to make information more findable</strong> - any del.icio.us user should know that. I used to install Ultimate Tag Warrior to get this feature - but WordPress now supports tags natively.</dd>
<dt>Searching</dt>
<dd><strong class="highlight">Searching for data within a database is much more easier, faster and provides more relevent results</strong> than searching for the data in a collection of file. Even if you are using a file indexing software like Google Desktop Search or Beagle/<a href="http://lindesk.com/2007/04/desktop-searching-in-linux-with-recoll/">Recoll</a>(for linux users), I find database searching more easier. Another advantage of using database to search is that you can <strong class="highlight">create complex queries if you know SQL</strong>.</dd>
</dl>
<h3>Disadvantages</h3>
<dl>
<dt>Not for everyone</dt>
<dd>Let&#8217;s face it - installing and maintaining a web/database server is a tad in the geek zone. An average Joe will find it just a little bit out of their league.</dd>
<dt>Overhead</dt>
<dd>Running a web server and a database server is a bit demanding on the RAM.</dd>
<dt>Backing up a little more complicated - but easier</dt>
<dd><a href="http://txt.binnyva.com/2007/03/mysql-database-backuprestore/">Backing up the data in a Database</a> is not as straight forward as backing up files - but its actually easier if you know how.</dd>
</dl>
<h2>Online</h2>
<p>One extra method to store the data - online.  This <strong class="highlight">data is stored in a database - but you don&#8217;t have the disadvantages associated with using a database</strong>. More and more people are turning to this method now. I did not include it in the initial list because its not a data format - its more of a data storing method.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/bin-blog?a=zIhnOJg"><img src="http://feeds.feedburner.com/~f/bin-blog?i=zIhnOJg" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=x7SdgQg"><img src="http://feeds.feedburner.com/~f/bin-blog?i=x7SdgQg" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=lMallEG"><img src="http://feeds.feedburner.com/~f/bin-blog?i=lMallEG" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bin-blog/~4/263494014" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/04/document-formats/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.bin-co.com/blog/2008/04/document-formats/</feedburner:origLink></item>
		<item>
		<title>Python Hello Script</title>
		<link>http://feeds.feedburner.com/~r/bin-blog/~3/254426143/</link>
		<comments>http://www.bin-co.com/blog/2008/03/python-hello-script/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 18:01:44 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
		
		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[example]]></category>

		<category><![CDATA[hello]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/03/python-hello-script/</guid>
		<description><![CDATA[
As promised in the last post(Hello Script for PHP), this is my Hello Script for Python. &#8216;Hello Script&#8216; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language.
A word of caution here - the blocks in [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.bin-co.com/blog/2008/03/python-hello-script/python-logo/' rel='attachment wp-att-97' title='Python Logo'><img src='http://www.bin-co.com/blog/wp-content/uploads/2008/03/python-logo.gif' alt='Python Logo' class="intro" align="right" /></a></p>
<p class="intro">As promised in the last post(<a href="http://www.bin-co.com/blog/2008/03/hello-script-for-php/">Hello Script for PHP</a>), this is my Hello Script for <a href="http://www.python.org/">Python</a>. <strong class="highlight">&#8216;<a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script</a>&#8216; is a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language.</p>
<p>A word of caution here - the blocks in Python is created using whitespace - so the indentation is important. So when you see an indentation in the below code, think of it as one tab(instead of four spaces or something).</p>
<p>I want to insert a disclaimer here - I am not that good with python. We <a href="http://www.bin-co.com/blog/2007/10/tk-verses-gtkand-python-verses-tcl/" title="	Tk Verses Gtk(And Python verses Tcl)">never really clicked</a>. I have done very limited <a href="http://www.bin-co.com/python/programs/frees/" title="Frees - PyGTK Tool to show HardDisk Space Usage">work in Python</a>. So if you notice any problems with the below script, let me know and I&#8217;ll correct it.</p>
<pre><code class="python">
#!/usr/bin/python

print "Hello World\n"

name = "Binny"
year = 2008
print "Hello, " + name + " - welcome to " + str(year) + "\n"

# If,else conditions
if (year &gt; 2008):
	print "Welcome to the future - yes, we have flying cars!\n"
elif(year &lt; 2008):
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all thats good and holy, stay away from your parents!\n"
else:
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo.\n"

# For loop
for i in range(0,3):
	print str(i) + ") Hi there!"

print ""

#Numerical Array, While
rules = ['Do no harm','Obey','Continue Living']
i = 0
while(i&lt;len(rules)):
	print &#8220;Rule &#8221; + str(i+1) + &#8221; : &#8221; + rules[i]
	i = i + 1
print &#8220;&#8221;

# Associated array, foreach
associated = {
	&#8216;hello&#8217;	:	&#8216;world&#8217;,
	&#8216;foo&#8217;	:	&#8216;bar&#8217;,
	&#8216;lorem&#8217;	:	&#8216;ipsum&#8217;
}
for key in associated:
	print key + &#8221; : &#8221; + associated[key]
print &#8220;&#8221;

import string
csv_values = string.split(&#8221;hello,world,how,are,you\n&#8221;, &#8220;,&#8221;)
print string.join(csv_values, &#8220;:&#8221;)

# Function, argument, return, call
def hello(name):
	return &#8220;Hello &#8221; + name + &#8220;\n&#8221;

hello_string = hello(&#8221;Binny&#8221;)
print hello_string

# One for the OOP fanboys - Class, members, object and stuff.
class Movie:
	name = &#8221;
	rating = 0

	def __init__(self, name):
		self.name = name
		self.rateMovie()

	def rateMovie(self):
		self.rating = (len(self.name) % 10) + 1 #IMDBs rating algorithm. True story!

	def printMovieDetails(self):
		print &#8220;Movie : &#8220;,  self.name
		print &#8220;Rating : &#8220;, &#8216;*&#8217; * self.rating , &#8220;(&#8221;, self.rating ,&#8221;)\n&#8221;

#Create the object
ncfom = Movie(&#8221;New Country for Old Men&#8221;) #It&#8217;s a sequel!
ncfom.printMovieDetails()

# File IO
# File reading, easy method&#8230;
file_in  = open(&#8217;Hello.py&#8217;, &#8216;r&#8217;)
contents = file_in.read()
print &#8220;Current file has &#8221; + str(len(contents)) + &#8221; chars\n&#8221;
file_in.close()
# Writing to a file
file_out = open(&#8217;/tmp/hello.txt&#8217;, &#8216;w&#8217;)
file_out.write(&#8221;Hello World&#8221;)
file_out.close()

# Command Executing
import commands
import os
print &#8220;Result of &#8216;ls&#8217; command is &#8221; + commands.getoutput(&#8217;ls&#8217;) #Execute the command &#8216;ls&#8217; and print its output
print

# Regular Expressions
import re
hell_check = re.compile(&#8221;^Hell&#8221;)
string = &#8220;Hello World&#8221;
if hell_check.match(string): print &#8220;Yup - its evil (Compiled)&#8221;
if re.match(&#8217;^Hell&#8217;, string): print &#8220;Yup - its evil (Not Compiled)&#8221;
print re.sub(r&#8217;l([^l])&#8217;, r&#8217;\1&#8242;, string)

</code></pre>
<p>As I said last time, save this to a file and keep it around for future reference.</p>
<p>Next hello script - Perl, Ruby or Tcl/Tk? Which one do you want - leave it in the comments.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/bin-blog?a=lU0mMxf"><img src="http://feeds.feedburner.com/~f/bin-blog?i=lU0mMxf" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=AYd4DQf"><img src="http://feeds.feedburner.com/~f/bin-blog?i=AYd4DQf" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=eMll0PF"><img src="http://feeds.feedburner.com/~f/bin-blog?i=eMll0PF" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bin-blog/~4/254426143" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/03/python-hello-script/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.bin-co.com/blog/2008/03/python-hello-script/</feedburner:origLink></item>
		<item>
		<title>Hello Script for PHP</title>
		<link>http://feeds.feedburner.com/~r/bin-blog/~3/252060072/</link>
		<comments>http://www.bin-co.com/blog/2008/03/hello-script-for-php/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 17:44:25 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Scripts]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[hello]]></category>

		<category><![CDATA[script]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/03/hello-script-for-php/</guid>
		<description><![CDATA[In the last post I introduced the concept of &#8216;Hello Script&#8217; - a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet when working with that language. I thought I can elaborate on that concept by creating Hello Scripts for all the [...]]]></description>
			<content:encoded><![CDATA[<p class="intro">In the last post I introduced the concept of <strong>&#8216;Hello Script&#8217; - a file that contains the most commonly used elements of a programming language so that it can be used as a cheat sheet</strong> when working with that language. I thought I can elaborate on that concept by creating Hello Scripts for all the languages that I am familiar with.</p>
<p>Let&#8217;s start with PHP - I already provided this as an example for the last post. Here is the entire PHP Hello Script&#8230;</p>
<pre><code class="php">
&lt;?php
// Printing(IO)
print "Hello World!\n";

// Variables, concatenation
$name = 'Binny';
$year = 2008;
print "Hello, " . $name . " - welcome to " . $year . "\n";

//If,else conditions
if ($year &gt; 2008) {
	print "Welcome to the future - yes, we have flying cars!";
}
else if($year &lt; 2008) {
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!";
}
else {
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo.";
}
print "\n";

// For loop
for($i=0; $i&lt;3; $i++) {
	print "$i) Hi there!\n";
}

//Numerical Array, While
$rules = array(
	'Do no harm',
	'Obey',
	'Continue Living'
);
$i = 0;
while($i&lt;count($rules)) {
	print "Rule " . ($i+1) . " : " . $rules[$i] . &#8220;\n&#8221;;
	$i++;
}

// Associated array, foreach
$associated = array(
	&#8216;hello&#8217;	=&gt;	&#8216;world&#8217;,
	&#8216;foo&#8217;	=&gt;	&#8216;bar&#8217;,
	&#8216;lorem&#8217;	=&gt;	&#8216;ipsum&#8217;
);
foreach($associated as $key =&gt; $value) {
	print &#8220;$key: $value\n&#8221;;
}

// Using Join and Split
$csv_values = explode(&#8217;,', &#8220;hello,world,how,are,you\n&#8221;);
print implode(&#8221;:&#8221;, $csv_values);

// Function, argument, return, call
function hello($name) {
	return &#8220;Hello &#8221; . $name;
}
$hello_string = hello(&#8221;Binny&#8221;);

// One for the OOP fanboys - Class, members, object and stuff.
class Movie {
	public $name = &#8221;;
	public $rating = 0;

	function __construct($name) {
		$this-&gt;name = $name;
		$this-&gt;rateMovie();
	}
	function rateMovie() {
		$this-&gt;rating = (strlen($this-&gt;name) % 10) + 1; //IMDBs rating algorithm. True story!
	}

	function printMovieDetails() {
		print &#8220;Movie : {$this-&gt;name}\n&#8221;;
		print &#8220;Rating : &#8221; . str_repeat(&#8217;*', $this-&gt;rating) . &#8220;({$this-&gt;rating})\n\n&#8221;;
	}
}
//Create the object
$ncfom = new Movie(&#8221;New Country for Old Men&#8221;); //It&#8217;s a sequel!
$ncfom-&gt;printMovieDetails();

// File IO
// File reading, easy method&#8230;
$contents = file_get_contents(&#8217;Hello.php&#8217;);
print &#8220;Hello has &#8221; . strlen($contents) . &#8221; chars\n&#8221;;
// Writing to a file
$file_handle = f<span></span>open(&#8217;/tmp/hello.txt&#8217;, &#8216;w&#8217;);
fputs($file_handle, &#8220;Hello World&#8221;);
fclose($file_handle);

// Command Executing
print `ls`; //Execute the command &#8216;ls&#8217; and print its output
print &#8220;\n&#8221;;

// Regular Expressions
$string = &#8220;Hello World&#8221;;
if(preg_match(&#8217;/^Hell/&#8217;, $string)) print &#8220;Yup - its evil\n&#8221;;
print preg_replace(&#8217;/l([^l])/&#8217;, &#8220;$1&#8243;, $string); //Remove an &#8216;l&#8217; from both words. Should print &#8216;Helo Word&#8217;

/*
 * Specialized code
 */
// Database connectivity(native)
mysql_connect(&#8217;localhost&#8217;, &#8216;root&#8217;, &#8221;) or die(&#8221;Cannot connect to the Database server&#8221;);
mysql_select_db(&#8217;Data&#8217;) or die(&#8217;Could not find a database called &#8220;Data&#8221;&#8216;);

// Executing Query
$sql_handle = mysql_query(&#8217;SELECT name,url,description FROM Comment LIMIT 1&#8242;) or die(&#8217;Query Error: &#8216; . mysql_error());
while($row = mysql_fetch_assoc($sql_handle)) {
	print &#8220;Name	:	$row[name]\n&#8221;;
	print &#8220;URL	:	$row[url]\n&#8221;;
	print &#8220;Desc	:	$row[description]\n\n&#8221;;
}
/* Just a note here - if you are going to use PHP with database in a production
 * system(and you will, trust me), use a Database abstraction layer rather than
 * the above mentioned native methods.
 */

print $_REQUEST['username']; // Method to get the value of the field &#8216;username&#8217; after a form submit. Will not work at CLI execution
</code></pre>
<p>Save this to a file and keep it around for future reference - if you are just starting out with PHP</p>
<p>Coming up next - Python Hello Script.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/bin-blog?a=4q16Wuf"><img src="http://feeds.feedburner.com/~f/bin-blog?i=4q16Wuf" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=Hsubbyf"><img src="http://feeds.feedburner.com/~f/bin-blog?i=Hsubbyf" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=Xlz6y3F"><img src="http://feeds.feedburner.com/~f/bin-blog?i=Xlz6y3F" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bin-blog/~4/252060072" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/03/hello-script-for-php/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.bin-co.com/blog/2008/03/hello-script-for-php/</feedburner:origLink></item>
		<item>
		<title>Learning a New Programming Language: The ‘Hello World’ Method</title>
		<link>http://feeds.feedburner.com/~r/bin-blog/~3/246858006/</link>
		<comments>http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 17:15:39 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
		
		<category><![CDATA[Opinion]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[hello]]></category>

		<category><![CDATA[language]]></category>

		<category><![CDATA[learning]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[world]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/</guid>
		<description><![CDATA[
Learning a new programming language is fun - and essential if you want to stay competitive. I try to learn new languages all the time(my latest target is Haskell). As a result, I have a system to make learning new languages easier. This is for people who already know a programming language and want to [...]]]></description>
			<content:encoded><![CDATA[<p><img class="intro" align="right" src='http://www.bin-co.com/blog/wp-content/uploads/2008/03/hello.jpg' alt='Hello World Learning' /></p>
<p class="intro">Learning a new programming language is fun - and essential if you want to stay competitive. I try to learn new languages all the time(my latest target is Haskell). As a result, I have a system to make learning new languages easier. This is for people who already know a programming language and want to learn another one.</p>
<h2>Requirements</h2>
<h3>What you must have&#8230;</h3>
<dl>
<dt>The interpreter/compiler of the language you are learning</dt>
<dd>You must be able to run the program after writing it.</dd>
<dt>Language reference manual/documentation</dt>
<dd>Usually found at the site of the language. Put a shortcut to that on your desktop - because you will be using this all the time.</dd>
<dt>An easy to follow tutorial</dt>
<dd>Search for it in Google. If you find one and its hard to follow, ditch it and get another. You may not need this - as manual for most languages have a tutorial in them.</dd>
<dt>A &#8216;todo&#8217; project that you cannot live without</dt>
<dd>This is what forces you to learn the language - more on this later.</dd>
</dl>
<h3>What I would recommend you have&#8230;</h3>
<p>Having this will help you learn - but its not necessary.</p>
<dl>
<dt>A Net Connection</dt>
<dd>You may want to ask your doubt on the IRC channel. Or on a forum. Or to google the error message you got.</dd>
<dt>A Decent IDE</dt>
<dd>This may make your job easier - but if you have notepad, that&#8217;s enough.</dd>
</dl>
<h3>What you don&#8217;t need</h3>
<dl>
<dt>Books on the language</dt>
<dd>You may need a book to master the language - but you don&#8217;t need one to learn it.</dd>
<dt>A Teacher</dt>
<dd>Its helpful to have someone to clarify the doubts you may have - but <strong class="highlight">no one can teach you anything you cannot learn yourself</strong>.</dd>
</dl>
<h2>The Hello World Script</h2>
<p>First you have to create the &#8216;hello world&#8217; application. This is more than just &#8216;print &#8220;Hello World&#8221;&#8216; - it will act as a <strong class="highlight">cheatsheet for you until you familiarize yourself with the language</strong>. The point of this application is to use <strong class="highlight">all the most commonly used elements of a language and putting it in a single place</strong> so that you can refer to it later.</p>
<p>Your first job is to go to the tutorial, the manual and the internet until you create the Hello World application with the following stuff in it. I will provide an example - how the &#8216;hello world&#8217; application will look in PHP.</p>
<p>After each step run the application and make sure it works.</p>
<dl>
<dt>Print &#8220;Hello World\n&#8221;</dt>
<dd>
<p>Why do you think we call it a hello world application? Write the code to <strong class="highlight">print a string &#8216;hello world&#8217; and save it</strong> to a file. Now <strong class="highlight">run it using the interpreter</strong> - and make sure it works - see it in action.</p>
<pre><code class="php">
// Printing(IO)
print "Hello World!\n";
	</code></pre>
</dd>
<dt>Comments</dt>
<dd>
<p>Put a single line comment(like //) on top of the &#8220;print &#8216;hello world&#8217;&#8221; code and if your language supports it, a multiline comment(/* - */) as well. Run the script to make sure the comments work as advertised.</p>
<pre><code class="php">
// Single line comment.
/*
Mulitline comment.
*/
	</code></pre>
<p>I was just kidding about running the script to test the comments - you did&#8217;nt do it, did you?</p>
</dd>
<dt>Use a variable(a string and an integer) and a concatenation operator.</dt>
<dd>
<p>Create a variable called name(string) - and give it your name as the value. Create another integer variable and give it the current year. You don&#8217;t have to find it programatically - just put it as 2008 or something. Now you have to print out the a string &#8220;Hello, &lt;name&gt; - Welcome to year &lt;$year&gt;&#8221;. This string will let you concatenate two different type variable to a string - and it makes me feel like a time traveler ;-).</p>
<p>Yeah - the value of variable name should appear at &lt;name&gt;. Use the concatenation operator if possible - in PHP, write</p>
<pre><code class="php">print "Hello, " . $name . " - welcome to year " . $year;</code></pre>
<p>instead of </p>
<pre><code class="php">print "Hello, $name - welcome to year $year";</code></pre>
<p>This is because different languages have different concatenation operators. The other stuff is the same almost universally. + refers to addition. - refers to subtraction. * is multiplication. My point is that <strong class="highlight">if you know the operators for one language, you know the operators for almost all languages</strong>. But the concatenation operator differs from language to language - its &#8216;+&#8217; in javascript, ruby. Its &#8216;.&#8217; in Perl, PHP, etc.</p>
<p>There are exceptions to this rule - &#8216;=&#8217; is the equality operator in SQL while it all other language its &#8216;==&#8217;. The assignment operator is &#8216;:=&#8217; in pascal - in all other it is &#8216;=&#8217;. If you notice any difference in any operator write some code using that operator in this section.</p>
</dd>
<dt>Use if/else if/else</dt>
<dd>
<p>Create something like this pseudo code&#8230;</p>
<pre><code class="pseudo">if (year &gt; 2008) {
	print "Welcome to the future - yes we have flying cars!"
}
else if(year &lt; 2008) {
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and holy, stay away from your parents!"
}
else {
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo."
}</code></pre>
<p>In PHP, this section will look like this&#8230;</p>
<pre><code class="php">//If,else conditions
if ($year &gt; 2008) {
	print "Welcome to the future - yes, we have flying cars!";
}
else if($year &lt; 2008) {
	print "The past - please don't change anything. Don't step on any butterflies. And for the sake of all that's good and decent, stay away from your parents!";
}
else {
	print "Anything wrong with your time machine? You have not gone anywhere, kiddo.";
}
print "\n";
	</code></pre>
<p>If you use switch(and the new language supports switch), you can write an example of switch here. </p>
</dd>
<dt>Print &#8216;Hi there!&#8217; 3 times using a for loop</dt>
<dd>
<p>A PHP example of using for loop(my all time favorite loop)&#8230;</p>
<pre><code class="php">// For loop
for($i=0; $i&lt;3; $i++) {
	print "$i) Hi there!\n";
}
	</code></pre>
</dd>
<dt>Create a list(array) and iterate through it using while/for/foreach loop.</dt>
<dd>
<p>I am using a while loop here - to keep things different&#8230;</p>
<pre><code class="php">
//Numerical Array, While
$rules = array(
	'Do no harm',
	'Obey',
	'Continue Living'
);
$i = 0;
while($i&lt;count($rules)) {
	print "Rule " . ($i+1) . " : " . $rules[$i] . &#8220;\n&#8221;;
	$i++;
}	</code></pre>
</dd>
<dt>Create a hash(associative array) and iterate through it.</dt>
<dd>
<p>If the language you are going to learn have &#8216;foreach&#8217;, this maybe the best time to use it&#8230;</p>
<pre><code class="php">// Associated array, foreach
$associated = array(
	'hello'	=>	'world',
	'foo'	=>	'bar',
	'lorem'	=>	'ipsum'
);
foreach($associated as $key => $value) {
	print "$key: $value\n";
}</code></pre>
</dd>
<dt>Create a function with an argument and a return.</dt>
<dd>
<p>If you need, you can create an example for call by reference, optional arguments, default argument value, variable argument count etc. as well - but they are not essential. Make sure you include the code to call a function as well.</p>
<pre><code class="php">// Function, argument, return, call
function hello($name) {
	return "Hello " . $name;
}
$hello_string = hello("Binny");</code></pre>
</dd>
</dl>
<h3>Optional Code</h3>
<p>I don&#8217;t usually included some of these in my &#8216;hello world&#8217; scripts - but they can be useful in some cases. Some may find them useful - so if you think you are going to use any of these, include it in your file.</p>
<dl>
<dt>Class, Objects, Member variables and functions</dt>
<dd>
<p>If you are a big fan of OOP, create the code for a class. Make sure it has all the following elements&#8230;</p>
<ul>
<li>At least one member variable</li>
<li>At least two member functions</li>
<li>Access the member variable and the other function from within a member function.</li>
<li>Create an object of this class</li>
<li>Call a member function using the object.</li>
</ul>
<pre><code class="php">// One for the OOP fanboys - Class, members, objects and stuff.
class Movie {
	public $name = '';
	public $rating = 0;

	function __construct($name) {
		$this-&gt;name = $name;
		$this-&gt;rateMovie();
	}
	function rateMovie() {
		$this-&gt;rating = (strlen($this-&gt;name) % 10) + 1; //IMDBs rating algorithm. True story!
	}

	function printMovieDetails() {
		print "Movie : {$this-&gt;name}\n";
		print "Rating : " . str_repeat('*', $this-&gt;rating) . "({$this-&gt;rating})\n\n";
	}
}
//Create the object
$ncfom = new Movie("New Country for Old Men"); //It's a sequel!
$ncfom-&gt;printMovieDetails();
</code></pre>
</dd>
<dt>File IO</dt>
<dd>
<p>Include this code - it is sure to come in useful someday. Unless you are learning JavaScript.</p>
<pre><code class="php">// File IO
// File reading, easy method...
$contents = file_get_contents('hello.php');
// Writing to a file
$file_handle = fop<span></span>en(&#8217;/tmp/hello.txt&#8217;, &#8216;w&#8217;);
fputs($file_handle, &#8220;Hello World&#8221;);
fclose($file_handle);
	</code></pre>
</dd>
<dt>Command Execution</dt>
<dd>
<p>I tend to include this - but it may be unnecessary for you.</p>
<pre><code class="php">// Command Executing
print `ls`; //Execute the command 'ls' and print its output</code></pre>
</dd>
<dt>Regular Expressions</dt>
<dd>
<p>I always include them - I am a big fan of regular expressions. I have lost count of how many times <a href="http://xkcd.com/208/">they have saved the day</a>.</p>
<pre><code class="php">// Regular Expressions
$string = "Hello World";
if(preg_match('/^Hell/', $string)) print "Yup - its evil\n";
print preg_replace('/l([^l])/&#8217;, &#8220;$1&#8243;, $string); //Remove an &#8216;l&#8217; from both words. Should print &#8216;Helo Word&#8217;
	</code></pre>
</dd>
</dl>
<h3>Specialized Code</h3>
<p>The language you learn may have a specialized field which we may have not used yet. If so, put it down here.</p>
<p>If you are learning javascript, write some code to access DOM nodes here. If you are using PHP, database connectivity will go well here. If you are learning any web server side languages, write the code to fetch the POST/GET request values. For PHP, it may look something like this&#8230;</p>
<pre><code class="php">
// Database connectivity(native)
mysql_connect('localhost', 'root', '') or die("Cannot connect to the Database server");
mysql_select_db('Data') or die('Could not find a database called "Data"');

// Executing Query
$sql_handle = mysql_query('SELECT name,url,description FROM Comment LIMIT 1') or die('Query Error: ' . mysql_error());
while($row = mysql_fetch_assoc($sql_handle)) {
	print "Name	:	$row[name]\n&#8221;;
	print &#8220;URL	:	$row[url]\n&#8221;;
	print &#8220;Desc	:	$row[description]\n\n&#8221;;
}
// Just a note here - if you are going to use PHP with database in a production system(and you will, trust me), use a Database abstraction layer rather than the above mentioned native methods.

print $_REQUEST['username']; // Method to get the value of the field &#8216;username&#8217; after a form submit. Will not work at CLI execution
	</code></pre>
<h2>Project</h2>
<p>Next thing you need is <strong class="highlight">a project - which you are going to build using the new language</strong>. Some points that you have to look for when choosing the new project&#8230;</p>
<ol>
<li>It should not be a huge project.</li>
<li>At the same time, it should not be something trivial.</li>
<li>There must be something about the project which would force you to finish it.</li>
</ol>
<p>The third point needs a little explaining. You should not just pick any project that pops into your mind. It must be something that you need - something you could not live without. If it is important to you, you will have a <strong class="highlight">motivation to finish the project</strong>. Otherwise, you will drop the project at the first sign of trouble. But if its important to you, you will spend more time on it - you will look at documentation, post the problem in forums, ask others in IRC channels. And eventually, you will fix the problem. And you will finish the project.</p>
<p>While working on the project, keep the &#8216;hello world&#8217; open - you will find yourself referring to it often.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/bin-blog?a=EBQvF0f"><img src="http://feeds.feedburner.com/~f/bin-blog?i=EBQvF0f" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=fmeV1pf"><img src="http://feeds.feedburner.com/~f/bin-blog?i=fmeV1pf" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=R0N9yfF"><img src="http://feeds.feedburner.com/~f/bin-blog?i=R0N9yfF" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bin-blog/~4/246858006" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/</feedburner:origLink></item>
		<item>
		<title>Alertle Launched</title>
		<link>http://feeds.feedburner.com/~r/bin-blog/~3/232725112/</link>
		<comments>http://www.bin-co.com/blog/2008/02/alertle-launched/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 18:22:43 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
		
		<category><![CDATA[Events]]></category>

		<category><![CDATA[Personal]]></category>

		<category><![CDATA[Review]]></category>

		<category><![CDATA[Sites]]></category>

		<category><![CDATA[Web 2.0]]></category>

		<category><![CDATA[Web Development]]></category>

		<category><![CDATA[alertle]]></category>

		<category><![CDATA[application]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[reader]]></category>

		<category><![CDATA[rss]]></category>

		<category><![CDATA[web]]></category>

		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2008/02/alertle-launched/</guid>
		<description><![CDATA[
I am one of the geeks behind Alertle. Its a web based RSS Reader. I am responsible for a good amount of the JavaScript areas of this app  
Features

Single Page Application
The entire application is contained in a single page - everything is done through Ajax. I will not advice that you make something like [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.alertle.com/' title='Alertle Screenshot'><img src='http://www.bin-co.com/blog/wp-content/uploads/2008/02/alertle_screenshot.jpg' alt='Alertle Screenshot' class="intro" align="right" /></a></p>
<p class="intro">I am one of the geeks behind <a href="http://www.alertle.com/">Alertle</a>. Its a web based RSS Reader. I am responsible for a good amount of the JavaScript areas of this app <img src='http://www.bin-co.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h2>Features</h2>
<dl>
<dt>Single Page Application</dt>
<dd>The entire application is contained in a single page - everything is done through Ajax. I will not advice that you make something like this(its a maintenance nightmare) but I can say one thing about it - its Cool. With a capital &#8216;C&#8217;.</dd>
<dt>Keyboard Shortcuts</dt>
<dd>I got the idea of creating a <a href="http://www.openjs.com/scripts/events/keyboard_shortcuts/">Keyboard Shortcut Library for JavaScript</a> when I was working on this feature.</dd>
<dt>Autoplay</dt>
<dd>You can view articles as you are viewing a slideshow if you enable this.</dd>
<dt>Feedpacks</dt>
<dd>You can bunch a group of feeds together into a feedpack - and see all the posts from such a group together.</dd>
<dt>Sharing</dt>
<dd>You can share your feedpacks with other users</dd>
</dl>
<h3>Perfect for High Volume Feeds</h3>
<p>There is one major feature that sets Alertle appart from other RSS readers - it does not tell you if a post is read or not. Yeah, first you will think its a missing feature - but its not. I have used a lot of feed readers - once you subscribe to a couple of high volume feed - like say, BoingBoing or Slashdot or something, you can say goodbye to your sanity. It creates so many new items that the only way of staying away the mess is to click on the &#8216;Mark all as read&#8217; button once every four seconds. You know what I mean - I am sure <a href="http://www.problogger.net/archives/2007/03/01/34-reasons-why-readers-unsubscribe-from-your-blog/">you have unsubscribed from many feeds for this reason.</a></p>
<p>With alertle, you can subscribe all these high volume feeds. And there is no pressure to view all the posts.</p>
<p>If you are an info junkie, I can guaranty that your will get lost for hours in Alertle.</p>
<h2>Problems</h2>
<h3>IE is not Supported</h3>
<p>We are still working on this - and due to deadline constraints, we decided to release Alertle without IE support. So if you are an IE user, I am sorry - but What in the World are you Doing? Ditch that terrible browser and get a <a href="http://www.mozilla.com/en-US/firefox/">real browser</a> right now!</p>
<p>If we can get a few people to switch to firefox before we add support for IE, I will say that Alertle gone beyond and above the call of duty to make the web a better place! <img src='http://www.bin-co.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<h3>Posts don&#8217;t have a Read Flag (pun unintended)</h3>
<p>Um., yeah, I know - this is both an advantage and a disadvantage. This will prevent me from using Alertle for all my feeds. For my must-read feeds, I will still be using Google Reader. For the high volume stuff, I will use Alertle.</p>
<h2>Getting to Know Alertle</h2>
<p>So, what are you waiting for? Head over to Alertle and sign up for an account. Its FREE!</p>
<p>But if you are still unconvinced, here is a demo&#8230;</p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/ztQJ4ec1aWs&amp;rel=1"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/ztQJ4ec1aWs&amp;rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
<h2>Links</h2>
<ul>
<li><a href="http://www.alertle.com/">Alertle</a></li>
<li><a href="http://mashable.com/2008/02/07/alertle/">Masable&#8217;s take on Alertle</a></li>
<li><a href="http://blog.alertle.com/">Alertle Blog</a></li>
<li><a href="http://wiki.alertle.com/">Alertle Docs</a></li>
</ul>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~f/bin-blog?a=YZ8rO5e"><img src="http://feeds.feedburner.com/~f/bin-blog?i=YZ8rO5e" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=KJJrTde"><img src="http://feeds.feedburner.com/~f/bin-blog?i=KJJrTde" border="0"></img></a> <a href="http://feeds.feedburner.com/~f/bin-blog?a=9SrDOLE"><img src="http://feeds.feedburner.com/~f/bin-blog?i=9SrDOLE" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bin-blog/~4/232725112" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/02/alertle-launched/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.bin-co.com/blog/2008/02/alertle-launched/</feedburner:origLink></item>
	</channel>
</rss>
