<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bin-Blog &#187; Tutorials</title>
	<atom:link href="http://www.bin-co.com/blog/tag/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bin-co.com/blog</link>
	<description>Learn about the latest in Web Development - as soon as I do.</description>
	<lastBuildDate>Tue, 13 Oct 2009 18:55:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Interactive SQL Tutorial</title>
		<link>http://www.bin-co.com/blog/2009/02/interactive-sql-tutorial/</link>
		<comments>http://www.bin-co.com/blog/2009/02/interactive-sql-tutorial/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 19:00:44 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[gears]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=230</guid>
		<description><![CDATA[I have completed a tutorial that I have been working on for a long time. Its the <a href="http://www.bin-co.com/database/sql_tutorial/">Interactive SQL(Structured Query Language) Tutorial</a> - it teaches you the basics of SQL. SQL, for those of you who are unaware of it, is the language used to access and manipulate data within a database. It is very simple and very powerful.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2009/02/db.png" alt="Database SQL" title="Database SQL" width="158" height="155" class="alignnone size-full wp-image-231 intro" align="right" /></p>
<p class="intro">I have completed a tutorial that I have been working on for a long time. Its the <a href="http://www.bin-co.com/database/sql_tutorial/">Interactive SQL(Structured Query Language) Tutorial</a> &#8211; it teaches you the basics of SQL. SQL, for those of you who are unaware of it, is the language used to access and manipulate data within a database. It is very simple and very powerful.</p>
<h2>Interactive SQL Query Box</h2>
<p>The cool thing about the tutorial is that it is interactive &#8211; each vistor can have a personal sandboxed database in which they can run any query they want. I call it the interactive query box. You can test almost all the SQL statements in this box without worrying about data loss &#8211; all the data is stored temporarily in this system. But you will have to install an extension called Google Gears in your browser.</p>
<h3>Google Gears</h3>
<p><a href="http://gears.google.com/">Google Gears</a> is an open source browser extension that lets developers create web applications that can run offline. You can install it in Firefox and Internet Explorer. If you want to try out SQL queries as it is presented in the tutorial, you need this extension.</p>
<p>You can view the tutorial without this extension, but you will be missing out the coolest feature of the tutorial.</p>
<h2>Simple Tutorial</h2>
<p>I have tried to make the tutorial as simple as possible. If you have learned about RDBMS, you know there are stuff like Normal Forms and Cardinality and other brain numbing definitions. I have removed all but the <a href="http://www.bin-co.com/database/sql_tutorial/db_terms_meanings.php">most essential definitions in my tutorial</a> &#8211; it makes it easier to understand.</p>
<p>Even after removing the confusing definitions, I have apologized about the rest&#8230;</p>
<blockquote><p>Sorry if you find the definitions here a bit too much. Trust me &#8211; you are much better off here than if you are learning SQL from a database book. They are going to lay definitions on you till your eyes bleed. I have seen brave men die from too much exposure to definitions.</p></blockquote>
<h2>Its Funny</h2>
<p>I have learned a lot of languages and programming techniques by reading books and sites &#8211; and one thing I have noticed is that most of the material is unbelievably dry. Its extremely hard to keep your eyes open when you read them. That is why <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&amp;location=https%3A%2F%2Fwww.amazon.com%2Fs%3Fie%3DUTF8%26x%3D23%26ref%255F%3Dnb%255Fss%255F%26y%3D23%26field-keywords%3Dhead%2520first%26url%3Dsearch-alias%253Dstripbooks&amp;tag=binnva-20&amp;linkCode=ur2&amp;camp=1789&amp;creative=390957">head first books</a><img src="https://www.assoc-amazon.com/e/ir?t=binnva-20&amp;l=ur2&amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> are so popular &#8211; they made learning fun.</p>
<p>Its been a policy of mine to inject humor into such tutorials &#8211; if you have read any of my earlier tutorials, you would know that&#8230;</p>
<ul>
<li><a href="http://www.openjs.com/tutorials/basic_tutorial/">An Interactive JS Tutorial &#8211; The ABC of JavaScript</a></li>
<li><a href="http://www.openjs.com/tutorials/advanced_tutorial/">Advanced JavaScript Tutorial</a></li>
<li><a href="http://www.bin-co.com/tcl/tutorial/">Tcl/Tk Tutorial &#8211; Create GUI using Tk with Tcl Language</a></li>
<li><a href="http://www.bin-co.com/perl/tutorial/">Beginner&#8217;s Tutorial for CGI Perl Language</a></li>
<li><a href="http://www.bin-co.com/perl/perl_tk_tutorial/">Perl/Tk Tutorial &#8211; Create GUI with Perl&#8217;s Tk Module</a></li>
</ul>
<p>Also, I am a <a href="http://blog.binnyva.com/">humor blogger</a> &#8211; so this stuff comes easily to me.</p>
<p>What I am trying to say is that the new SQL tutorial follows the same pattern &#8211; there is a lot of humor in it. So people can read it easily &#8211; without resorting to caffeine shots.</p>
<h2>I Want Your Help&#8230;</h2>
<p>Now that the writing part is over, I am proof-reading it. I have corrected a fair amount of stupid mistakes so far &#8211; but I am sure that there are many still left. I was hoping that a few of you would head over to my <a href="http://www.bin-co.com/database/sql_tutorial/">SQL Tutorial</a> and go through it. If you notice any mistakes, just put it in the comment field at the end of each page. Once I fix an error, I&#8217;ll remove the comment &#8211; that way, when I launch the tutorial, people will think that there were no errors in my tutorial. Devious, isn&#8217;t it?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2009/02/interactive-sql-tutorial/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing lighttpd Web Server in Linux with PHP and MySQL</title>
		<link>http://www.bin-co.com/blog/2008/11/installing-lighttpd-web-server-in-linux-with-php-and-mysql/</link>
		<comments>http://www.bin-co.com/blog/2008/11/installing-lighttpd-web-server-in-linux-with-php-and-mysql/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 17:48:21 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=161</guid>
		<description><![CDATA[After <a href="http://www.bin-co.com/blog/2008/09/installing-lampapache-web-serverphpmysql-in-debian/" title="Installing LAMP(Apache Web Server/PHP/MySQL) in Debian">two articles</a> on <a href="http://www.bin-co.com/blog/2008/09/compile-install-lamp-linux-apache-mysql-php-server-from-source/" title="Compile and Install a LAMP(Linux/Apache/MySQL/PHP) Server from Source">installing Apache</a>, lets take a look at <strong class="highlight">installing and configuring lighttpd web server on a linux system</strong>. <a href="http://www.lighttpd.net/">lighttpd</a> (pronounced "lighty") is a web server designed to be secure, fast, standards-compliant and flexible while having a low memory footprint.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/11/lighttpd_logo.png" alt="lighttpd Web Server" title="Lighttpd Logo" width="200" height="197" class="alignnone size-full wp-image-160 intro" align="right" /></p>
<p class="intro">After <a href="http://www.bin-co.com/blog/2008/09/installing-lampapache-web-serverphpmysql-in-debian/" title="Installing LAMP(Apache Web Server/PHP/MySQL) in Debian">two articles</a> on <a href="http://www.bin-co.com/blog/2008/09/compile-install-lamp-linux-apache-mysql-php-server-from-source/" title="Compile and Install a LAMP(Linux/Apache/MySQL/PHP) Server from Source">installing Apache</a>, lets take a look at <strong class="highlight">installing and configuring lighttpd web server on a linux system</strong>. <a href="http://www.lighttpd.net/">lighttpd</a> (pronounced &#8220;lighty&#8221;) is a web server designed to be secure, fast, standards-compliant and flexible while having a low memory footprint.</p>
<p>Before installation, a few points to remember. These <strong class="highlight">instruction are not for a production environment &#8211; this is for a development environment</strong>. To install the software, <strong class="highlight">you need root access</strong>. You can get that using this command&#8230;</p>
<pre><code class="cli">su -
[Enter root password]</code></pre>
<p>or by prefixing &#8216;<code>sudo</code>&#8216; before each command.</p>
<h2>Installing the Server</h2>
<p>First install lighttpd and PHP &#8211; use your distro&#8217;s package management(yum, apt-get) system to do this.</p>
<h3>Install lighttpd</h3>
<p>You can use this command in Red Hat based systems(Fedora, Cent OS, etc.) to install lighttpd. Debian/Ubuntu systems might the same package name &#8211; could someone post the package name of lighttpd in the comments?</p>
<pre><code class="cli">yum install lighttpd lighttpd-fastcgi</code></pre>
<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/09/php-logo.png" alt="PHP Logo" title="PHP Logo" width="179" height="98" class="alignnone size-full wp-image-123" align="right" /></p>
<h3>Install PHP</h3>
<p>If you don&#8217;t have PHP, you can install it using the command&#8230;</p>
<pre><code class="cli">yum install php php-cli php-common</code></pre>
<p>In Debian/Ubuntu systems, the command is&#8230;</p>
<pre><code class="cli">apt-get install php5-cli php5-common php5-cgi</code></pre>
<p>You can make sure you have php-cgi(needed for working with lighttpd) by running this command&#8230;</p>
<pre><code class="cli">php-cgi -v</code></pre>
<h3>Installing MySQL</h3>
<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/09/mysql_logo.gif" alt="" title="MySQL Logo" width="150" height="98" class="alignnone size-full wp-image-127" align="right" /></p>
<p>If MySQL is not yet installed, use this command to install it&#8230;</p>
<pre><code class="cli">yum install mysql-server php-mysql mysql mysql-libs</code></pre>
<p>Debian/Ubuntu Command&#8230;</p>
<pre><code class="cli">apt-get install mysql-client mysql-common mysql-server php5-mysql</code></pre>
<h2>Configuring lighttpd</h2>
<p>lighttpd configuration is done by <strong class="highlight">editing the text file &#8216;/etc/lighttpd/lighttpd.conf&#8217;.</strong></p>
<p><strong class="highlight">Enable some lighttpd modules</strong> by removing the comment character(#) from the beginning of the line. I have enabled the following modules&#8230;</p>
<pre><code class="conf">server.modules              = (
                                "mod_rewrite",
                                "mod_redirect",
                                "mod_access",
                                "mod_fastcgi",
                                "mod_accesslog" )
</code></pre>
<p><strong class="highlight">Configure lighttpd&#8217;s document root</strong> &#8211; if you already have Apache, I would recommend using the same document root as Apache(applicable for development servers only). </p>
<pre><code class="conf">server.document-root        = "/var/www/"</code></pre>
<p>I find it helpful to <strong class="highlight">enable folder listing</strong> in my server.</p>
<pre><code class="conf">## virtual directory listings
dir-listing.activate       = "enable"</code></pre>
<h3>Turn On FastCGI PHP Support</h3>
<p>Now, make sure lighttpd works with PHP &#8211; first get the path of php-cgi using the command..</p>
<pre><code class="cli">$ whereis php-cgi
php-cgi: /usr/bin/php-cgi #Might be different on your system.</code></pre>
<p>Then <strong class="highlight">add the path to the configuration file</strong> of lighttpd&#8230;</p>
<pre><code class="conf">#### fastcgi module
## read fastcgi.txt for more info
## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini
fastcgi.server             = ( ".php" =>
                               ( "localhost" =>
                                 (
                                   "socket" => "/tmp/php.socket",
                                   <strong class="highlight">"bin-path" => "/usr/bin/php-cgi"</strong>
                                 )
                               )
                            )</code></pre>
<p>Make sure you <strong class="highlight">uncomment the above lines</strong> by removing the &#8216;#&#8217; characters.</p>
<p>After you are done, <strong class="highlight">save the file</strong>. Time to try out the server.</p>
<h2>Starting the lighttpd Server</h2>
<p>First stop Apache if it is running&#8230;</p>
<pre><code class="cli">/etc/init.d/httpd stop</code></pre>
<p>Now start lighttpd using the command</p>
<pre><code class="cli">/etc/init.d/lighttpd start</code></pre>
<p>Go to your document root(<code>/var/www</code>) and <strong class="highlight">create a php files called &#8216;info.php&#8217; and put this code</strong> inside it&#8230;</p>
<pre><code class="php">&lt;?php
php<!-- wordpress bug workaround -->Info();</code></pre>
<p>Now fire up a browser and <strong class="highlight">go to <a href="http://localhost/" title="Might not work if the preceding instructions where not followed">localhost</a></strong> &#8211; you should see a file listing page with a ‘info.php’ in the list. Click on that link &#8211; if you see a PHP information page, your web server is setup correctly.</p>
<p>To make sure MySQL-PHP connection is working, <a href="http://www.bin-co.com/database/clients/phpmyadmin/installing_phpmyadmin.php" title="Installing phpMyAdmin 2.8">install phpMyAdmin</a> &#8211; or write a database connection script &#8211; whatever is easier for you.</p>
<h2>Related Links</h2>
<ul>
<li><a href="http://www.lighttpd.net/">lighttpd fly light</a></li>
<li><a href="http://en.wikipedia.org/wiki/Lighttpd">lighttpd &#8211; Wikipedia</a></li>
<li><a href="http://cssgallery.info/lighttpd-install-perl-mysql-support-in-chrooted-jail/">Lighttpd install perl, mysql support in chrooted jail</a></li>
<li><a href="http://www.cyberciti.biz/tips/lighttpd-php-fastcgi-configuration.html">Lighttpd PHP fastcgi configuration</a></li>
<li><a href="http://www.cyberciti.biz/tips/howto-install-lighttpd-on-freebsd.html">FreeBSD Install Lighttpd Web Server</a></li>
<li><a href="http://fandar-it.com/content/view/35/32/">Install lighttpd with php</a></li>
<li><a href="http://wiki.vpslink.com/Install_and_Configure_lighttpd">Install and Configure lighttpd</a></li>
<li><a href="http://www.howtoforge.com/lighttpd_php5_mysql_fedora7">Installing Lighttpd With PHP5 And MySQL Support On Fedora 7</a></li>
</ul>
<p><strong class="highlight">Shameless Plug</strong>: If you are a Linux user, you may want to check out my <a href="http://lindesk.com/" title="Lindesk - Linux on the Desktop">Linux Blog &#8211; LinDesk</a> &#8211; its about Linux on the Desktop &#8211; Articles, Application Reviews and Tutorials about many aspects of Linux included configuration and scripting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/11/installing-lighttpd-web-server-in-linux-with-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hello Script for C Language</title>
		<link>http://www.bin-co.com/blog/2008/07/hello-script-for-c-language/</link>
		<comments>http://www.bin-co.com/blog/2008/07/hello-script-for-c-language/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 17:41:49 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[scirpt]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=116</guid>
		<description><![CDATA[C &#8211; the root of all modern language&#8217;s syntax. Here is the hello script for C. A &#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. C is a general-purpose, block structured, procedural, [...]]]></description>
			<content:encoded><![CDATA[<p class="intro">C &#8211; the root of all modern language&#8217;s syntax. Here is the hello script for C. A &#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 when working with that language.</p>
<blockquote><p>C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie. Although C was designed for implementing system software, it is also widely used for applications. It is widely used on a great many different software platforms and computer architectures, and several popular compilers exist.</p>
<p><a href="http://en.wikipedia.org/wiki/C_(programming_language)">Wikipedia</a></p></blockquote>
<p>Unfortunately, I am not an expert in C &#8211; I prefer dynamic languages over static ones. So if you find any problems in the script, please let me know in the comments.</p>
<pre><code class="c">
#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

// Function declaration
void hello(char name[]) {
 	char result[50] = "Hello, ";
 	strcat(result, name);
 	printf("%s\n", result);
}

int main() {
	int i;
	// Printing(IO)
	printf("Hello World!\n");

	// Variables, concatenation
	char name[] = "Binny";
	int year = 2008;
	printf("Hello, %s - welcome to %d\n", name, year);

	//If, else
	if (year &gt; 2008) {
		printf("Welcome to the future - yes, we have flying cars!");
	}
	else if(year &lt; 2008) {
		printf("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 {
		printf("Anything wrong with your time machine? You have not gone anywhere, kiddo.");
	}
	printf("\n");

	// For loop
	for(i=0; i&lt;3; i++) {
		printf("%d) Hi there!\n", i);
	}

 	//Numerical Array, while
 	char rules[3][20]; //I am sure there is a better way of doing this using poiters. If you know, please leave a few 'pointers' in the comment.
 	strcpy(rules[0], "Do no harm");
 	strcpy(rules[1], "Obey");
 	strcpy(rules[2], "Continue Living");
 	i=0;
	while(i&lt;3) {
		printf("Rule %d : %s\n", i+1, rules[i]);
		i++;
	}

	// Struct - nearest thing C has to an associated array
	struct structure {
		char hello[20];
		int number;
		char foo[20];
	} associated, new_associated;
	strcpy(associated.hello, "world");
	associated.number = 1337;
	strcpy(associated.foo, "bar");
	printf("hello: %s\n", associated.hello);
	printf("number: %d\n", associated.number);
	printf("foo: %s\n", associated.foo);

	// Function calling
	hello("John Oldman");

	// Writing to a file
 	FILE *out;
 	out = fop<!-- fix wordpress bug -->en("/tmp/Hello.txt", "w");
 	char *str = "Hello From C";
 	fputs(str, out);
 	fclose(out);

	// Reading and displaying a file.
	FILE *in;
	in = fop<!-- fix wordpress bug -->en("Hello.c", "r");
	if (in) {
		while (!feof(in))
			printf("%c",fgetc(in));
	}
	fclose(in);

	// Run a system command.
	sys<!-- fix wordpress bug -->tem("ls");

	return 1;
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/07/hello-script-for-c-language/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hello Script for Java</title>
		<link>http://www.bin-co.com/blog/2008/06/hello-script-for-java/</link>
		<comments>http://www.bin-co.com/blog/2008/06/hello-script-for-java/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 18:24:01 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=111</guid>
		<description><![CDATA[After the Hello Script for JavaScript, here is the Hello Script for Java. &#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. Warning: I am NOT an expert in Java &#8211; I am [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/06/java-logo.png" alt="" title="Java Logo" width="125" height="217" class="size-full wp-image-112 intro" align="right" /></p>
<p class="intro">After the <a href="http://www.bin-co.com/blog/2008/05/hello-script-for-javascript/">Hello Script for JavaScript</a>, here is the Hello Script for Java. <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>
<p>Warning: I am NOT an expert in Java &#8211; I am just a beginner. There <strikeout>may</strikeout> will be errors(bad programming methods &#8211; not compiler errors) in the following script. If you notice any such issues, please point them out in the comments.</p>
<h2>Code</h2>
<p>If you want to run the code, save it to a file named &#8216;Hello.java&#8217; and compile in using the command &#8216;javac Hello.java&#8217;. After that you can run the code using the command &#8216;java Hello&#8217;.</p>
<pre><code class="java">
import java.io.*;
import java.util.regex.*;

public class Hello {
	public static void main(String[] Args) {
		// Printing(IO)
		System.out.println("Hello World");

		// Variables, concatenation
		String name = "Binny";
		int year = 2008;

		System.out.println("Hello, " + name + " - welcome to " + year);

		if(year &gt; 2008) {
			System.out.println("Welcome to the future - yes, we have flying cars!");
		} else if(year &lt; 2008) {
			System.out.println("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 {
			System.out.println("Anything wrong with your time machine? You have not gone anywhere, kiddo.");
		}

		// For loop
		int i=0;
		for(i=0; i&lt;3; i++) {
			System.out.println(i + ") Hi there!");
		}

		//Numerical Array, While
		String rules[] = {"Do no harm", "Obey", "Continue Living"};
		i = 0;
		while(i&lt;rules.length) {
			System.out.println("Rule " + (i+1) + " : " + rules[i]);
			i++;
		}

		// Associated array, foreach
		// Hmm - does Java have Associated arrays? ArrayList?

		String csv_string = "hello,world,how,are,you";
		String csv_values[] = csv_string.split(",");
		// No native Join method

		// Function, argument, return, call
		System.out.println(Hello.hello("Binny")); //The function definition is at the end of this file.	

		//Class stuff...
		Movie ncfom = new Movie("New Country for Old Men"); //It's a sequel!
		ncfom.printMovieDetails();

		// File IO
		// File reading, easy method...
		try {
			File read_file = new File ("/tmp/Hello.txt");
			FileReader in_stream = new FileReader(read_file); // Create a Character Input Stream
			BufferedReader in = new BufferedReader(in_stream);// Filter the Input Stream - buffers characters for efficiency
			try {
				System.out.println(in.readLine()); // read the first line
			} catch(IOException E) {
				System.out.println("No idea what went wrong. Sorry!");
			}
		} catch(FileNotFoundException E) {
			System.out.println("File not found. Sorry!");
		}

		try {
			// Writing to a file
			File out_file = new File("/tmp/HelloJava.txt");
			FileOutputStream out_stream = new FileOutputStream(out_file); // Create an Output Stream
			PrintWriter out = new PrintWriter(out_stream); // Filter bytes to ASCII
			out.println("Hello, from Java"); // Here we actually write to file
		} catch(java.io.FileNotFoundException E) {
			System.out.println("File not found. Sorry!");
		}

		System.out.println("\nLS command results...");
		// Command Executing
		try {
			// Execute a command
			String command = "ls";
			Process child = Runtime.getRuntime().exec (command);

			// Read from an input stream
			InputStream in = child.getInputStream();
			int c;
			while ((c = in.read()) != -1) {
				System.out.print((char)c);
			}
			in.close();
		} catch (IOException e) {
			System.out.println("Error");
		}

		System.out.print("\n");
		//Regular Expression
		String str = new String("Hello World");

		//Find a pattern
		Pattern hell_check = Pattern.compile("^Hell");
		Matcher matches = hell_check.matcher(str);
		if(matches.find()) System.out.println("Yup - its evil");

		//Replace
		System.out.println(str.replaceAll("l([^l])", "$1")); //Remove an 'l' from both words. Should print 'Helo Word'

	}

	//Function declaration.
	private static String hello(String name) {
		return "Hello, " + name;
	}

	// One for the OOP fanboys - Class, members, object and stuff.
	private static class Movie {
		public String name = "";
		public int rating = 0;

		public Movie(String name) {
			this.name = name;
			this.rateMovie();
		}

		public void rateMovie() {
			this.rating = (this.name.length() % 10) + 1; //IMDBs rating algorithm. True story!
		}

		public void printMovieDetails() {
			System.out.println("Movie  : " + this.name);
			System.out.println("Rating : " + this.rating);
		}
	}
}
</code></pre>
<p>Next Hello Script &#8211; C</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/06/hello-script-for-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hello Script For JavaScript</title>
		<link>http://www.bin-co.com/blog/2008/05/hello-script-for-javascript/</link>
		<comments>http://www.bin-co.com/blog/2008/05/hello-script-for-javascript/#comments</comments>
		<pubDate>Thu, 22 May 2008 18:26:14 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[hello]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/?p=108</guid>
		<description><![CDATA[The next language to get the Hello Script treatment is JavaScript &#8211; my favorite language. Before we go any further, here is the definitions for Hello Script and JavaScript &#8211; just to make sure that we are on the same page&#8230; Hello Script &#8216;Hello Script&#8217; is a file that contains the most commonly used elements [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.bin-co.com/blog/wp-content/uploads/2008/05/javascript_logo.jpg" alt="Javascript Rhino Logo" title="Javascript Logo" width="230" height="194" class="alignnone size-full wp-image-109 intro" align="right" /></p>
<p class="intro">The next language to get the <a href="http://www.bin-co.com/blog/2008/03/learning-a-new-programming-language-the-hello-world-method/">Hello Script</a> treatment is <a href="http://www.openjs.com/">JavaScript &#8211; my favorite language</a>. Before we go any further, here is the definitions for Hello Script and JavaScript &#8211; just to make sure that we are on the same page&#8230;</p>
<dl>
<dt>Hello Script</dt>
<dd><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.</dd>
<dt><a href="http://localhost/Sites/openjs/openjs.com/about.php#about-js">JavaScript</a></dt>
<dd>JavaScript is a <strong class="highlight">client side scripting language</strong> that is used in browsers.</dd>
</dl>
<h2>Code</h2>
<p>Warning: Do not run this code &#8211; you will get a lot of alerts. If you have firebug extension, uncomment the first line &#8211; then you can run the code.</p>
<pre><code class="html">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Hello Script for JS&lt;/title&gt;
&lt;script type="text/javascript"&gt;
//alert=console.log;
alert("Hello World");

// Variables, concatination
var name = 'Binny';
var year = 2008;
alert("Hello, " + name + " - welcome to " + year );

//If,else conditions
if (year &gt; 2008) {
	alert("Welcome to the future - yes, we have flying cars!");
}
else if(year &lt; 2008) {
	alert("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!");
}
else {
	alert("Anything wrong with your time machine? You have not gone anywhere, kiddo.");
}

// For loop
for(var i=0; i&lt;3; i++) {
	alert(i + ") Hi there!");
}

//Numerical Array, While
var rules = [
	'Do no harm',
	'Obey',
	'Continue Living'
];
var i = 0;
while(i&lt;rules.length) {
	alert("Rule " + (i+1) + " : " + rules[i]);
	i++;
}

// Associated array, foreach
var associated = {
	'hello'	:	'world',
	'foo'	:	'bar',
	'lorem'	:	'ipsum'
}
for(key in associated) {
	alert(key + " : " + associated[key]);
}

// Using Join and Split
csv_values = "hello,world,how,are,you".split(",");
alert(csv_values.join(":"));

// Function, argument, return, call
function hello(name) {
	return "Hello " + name;
}
hello_string = hello("Binny");
alert(hello_string);

// One for the OOP fanboys - Class, members, object and stuff.
function Movie(name) { //Constuctor
	this.name = name;
}
Movie.prototype.rateMovie = function() {
	this.rating = (this.name.length % 10) + 1; //IMDBs rating algorithm. True story!
}

Movie.prototype.printMovieDetails = function() {
	alert("Movie : " + this.name + "\nRating : " + this.rating);
}

//Create the object
ncfom = new Movie("New Country for Old Men"); //It's a sequel!
ncfom.printMovieDetails();

// Regular Expressions
string = "Hello World";
if(string.match(/^Hell/)) alert("Yup - its evil\n");
alert(string.replace(/l([^l])/g, "$1")); //Remove an 'l' from both words. Should alert('Helo Word'

/**
 * Specialized code
 */
window.onload = function() {
	var ele = document.getElementById("div-element");
	alert(ele);
	ele.innerHTML = "Hello World";
	ele.onclick = function() {
		alert("You Clicked?");
	}

	document.getElementById("text").value = "Goodbye World";
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;div id="div-element"&gt;&lt;/div&gt;

&lt;input type="text" value="3" id="text" /&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/05/hello-script-for-javascript/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hello Script for Tcl</title>
		<link>http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/</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[Tutorials]]></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 &#8211; its the language that introduced me [...]]]></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 &#8211; 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 &#8211; 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 "Welcome to the future - yes, we have flying cars!" 

} elseif { $year &lt; 2008 }  {
	 puts "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 {
	 puts "Anything wrong with your time machine? You have not gone anywhere, kiddo."
}

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

#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] " : "  [lindex $rules $i]]
	incr i
}

# Associated array, while
array set associated {
	hello	"world"
	foo		"bar"
	lorem	"ipsum"
}

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...
set IN [open "Hello.tcl" r]
set contents [read $IN]
close $IN
puts [concat "Hello has " [string length $contents] " chars"]

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

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

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>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/04/hello-script-for-tcl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl Hello Script</title>
		<link>http://www.bin-co.com/blog/2008/04/perl-hello-script/</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[Tutorials]]></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 &#8211; 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 [...]]]></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> &#8211; 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 'l' from both words. Should print 'Helo Word'
print $string;

print "\n\n";
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/04/perl-hello-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Python Hello Script</title>
		<link>http://www.bin-co.com/blog/2008/03/python-hello-script/</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[Tutorials]]></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 &#8211; the blocks [...]]]></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 &#8211; the blocks in Python is created using whitespace &#8211; 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 &#8211; 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 "Rule " + str(i+1) + " : " + rules[i]
	i = i + 1
print ""

# Associated array, foreach
associated = {
	'hello'	:	'world',
	'foo'	:	'bar',
	'lorem'	:	'ipsum'
}
for key in associated:
	print key + " : " + associated[key]
print ""

import string
csv_values = string.split("hello,world,how,are,you\n", ",")
print string.join(csv_values, ":")

# Function, argument, return, call
def hello(name):
	return "Hello " + name + "\n"

hello_string = hello("Binny")
print hello_string

# One for the OOP fanboys - Class, members, object and stuff.
class Movie:
	name = ''
	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 "Movie : ",  self.name
		print "Rating : ", '*' * self.rating , "(", self.rating ,")\n"

#Create the object
ncfom = Movie("New Country for Old Men") #It's a sequel!
ncfom.printMovieDetails()

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

# Command Executing
import commands
import os
print "Result of 'ls' command is " + commands.getoutput('ls') #Execute the command 'ls' and print its output
print

# Regular Expressions
import re
hell_check = re.compile("^Hell")
string = "Hello World"
if hell_check.match(string): print "Yup - its evil (Compiled)"
if re.match('^Hell', string): print "Yup - its evil (Not Compiled)"
print re.sub(r'l([^l])', r'\1', 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 &#8211; Perl, Ruby or Tcl/Tk? Which one do you want &#8211; leave it in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/03/python-hello-script/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Hello Script for PHP</title>
		<link>http://www.bin-co.com/blog/2008/03/hello-script-for-php/</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[Tutorials]]></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; &#8211; 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; &#8211; 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 &#8211; 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] . "\n";
	$i++;
}

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

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

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

// One for the OOP fanboys - Class, members, object 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();

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

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

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

/*
 * Specialized code
 */
// 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";
	print "URL	:	$row[url]\n";
	print "Desc	:	$row[description]\n\n";
}
/* 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 'username' 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 &#8211; if you are just starting out with PHP</p>
<p>Coming up next &#8211; Python Hello Script.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2008/03/hello-script-for-php/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Web Application Installer</title>
		<link>http://www.bin-co.com/blog/2007/07/web-application-installer/</link>
		<comments>http://www.bin-co.com/blog/2007/07/web-application-installer/#comments</comments>
		<pubDate>Sun, 01 Jul 2007 18:07:17 +0000</pubDate>
		<dc:creator>Binny V A</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[basic]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[installer]]></category>
		<category><![CDATA[nexty]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.bin-co.com/blog/2007/07/web-application-installer/</guid>
		<description><![CDATA[Almost all distributed web applications has an installer &#8211; it makes installation process easier for the end user. I will try to outline some of the most important things to look out for when creating an installer. Examples of Web Installers WordPress Joomla Nexty I have created an installer for Nexty &#8211; I used the [...]]]></description>
			<content:encoded><![CDATA[<p class="intro">Almost all distributed web applications has an installer &#8211; it makes installation process easier for the end user. I will try to outline some of the most important things to look out for when creating an installer.</p>
<h2>Examples of Web Installers</h2>
<h3><a href="http://wordpress.org/">WordPress</a></h3>
<p><a href='http://www.bin-co.com/blog/wp-content/uploads/2007/07/wordpress.png' title='WordPress Installer Screenshot'><img src='http://www.bin-co.com/blog/wp-content/uploads/2007/07/wordpress.thumbnail.png' alt='WordPress Installer Screenshot' /></a></p>
<h3><a href="http://www.joomla.com/">Joomla</a></h3>
<p><a href='http://www.bin-co.com/blog/wp-content/uploads/2007/07/joomla.png' title='Joomla Installer Screenshot'><img src='http://www.bin-co.com/blog/wp-content/uploads/2007/07/joomla.thumbnail.png' alt='Joomla Installer Screenshot' /></a></p>
<h3>Nexty</h3>
<p>I have created an installer for Nexty &#8211; I used the same installer for <a href="http://www.bin-co.com/blog/2007/05/jus5-light-weight-cms/">Jus5</a> as well. Here&#8217;s a screenshot&#8230;</p>
<p><a href='http://www.bin-co.com/blog/wp-content/uploads/2007/07/nexty.png' title='Nexty Installer Screenshot'><img src='http://www.bin-co.com/blog/wp-content/uploads/2007/07/nexty.thumbnail.png' alt='Nexty Installer Screenshot' /></a></p>
<h2>Functions of an Installer</h2>
<h3>Check Requirements</h3>
<p>If you software needs the GD PHP extension, check for it &#8211; it it is not present, show an error. If any folder must be writable, check for that. Make sure that the user cannot go to the next page without solving all the problems.</p>
<p>Make sure you have provided clear instructions on how to solve the problems &#8211; changing the permission might be easy for you and me &#8211; but the average user will find it very hard.</p>
<h3>Database Connection Details</h3>
<p>The user have to provide this data if our system uses a database.</p>
<ul>
<li>Host</li>
<li>User</li>
<li>Password</li>
<li>Database</li>
</ul>
<p>In some applications, the user must manually enter these data into the config file(for eg. WordPress). In other software, the user have to enter it at the time of installation. For example, Joomla uses this method &#8211; as does my application, <a href="http://nexty.sourceforge.net/">Nexty</a>.</p>
<h3>Create tables and insert initial data</h3>
<p>Check for existing data first &#8211; you don&#8217;t want to delete the existing data when reinstalling the software. This step is necessary only if you are using a Database in your application.</p>
<h3>Save the inputted data</h3>
<p>The user inputted data must be saved &#8211; in my application I just write it to the config file. But for that to work, the config file must have write permission. I also give the user an option to copy the code and place it in the config file themself.</p>
<p>Joomla also writes the values to a config file. However, WordPress inserts the data into the database. The only thing in the config file in wordpress is the database connection details &#8211; which the user must enter manually.</p>
<h3>Disable the Installer</h3>
<p>Make sure that the installer cannot be run after the installation is successfully compleated. This is important for the security of the application. You really don&#8217;t want any Yahoos opening up the install URL of your application and resetting all the data!</p>
<p>The easiest way of doing this is just deleting the installation script/folder. Joomla insists that you remove the installation folder before letting you use the application. In Nexty, removing the installation directory is recommended &#8211; but not enforced.</p>
<p>More on Web Installers in the next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bin-co.com/blog/2007/07/web-application-installer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

