Javascript Snake Game

This is a very simple snake game written by me. It has been entirely written in javascript.Please send in some comments and suggestions if you like it .

Click on Start Button. Use Arrow Keys to navigate.

Copyrights 2006 -2019 Ashish Patil []. Permission granted to use/modiy this script for any reason with following RESTRICTIONS:
1] You WILL RETAIN this original notice.This notice should be also included in derivative works
2] You will include a notice on the page running this script which says "Copyrights 2006 Ashish Patil []"
3] The page running the script should have link to

Transliteration Tools for Indian Languages

Do you frequently type Marathi or Hindi using English alphabets . Ever wished you could write your stuff in Devanagari , without much hassles, then you should definitely read this.Transliteration is process of converting letters of one language to their phonetic equivalent representation in another . In simple language if you type ‘Kaise ho‘ you should get ‘कैसे हो‘ . Imagine how easy and fast it would make typing your mother tongue .

  • kaay kam karato = क्या काम कर रहे हो
  • kyaa chal rahaa hai = क्या चल रहा है

If you ever tried writing in Devanagari into your text editor then you must be very well aware of special fonts that one has to install on his/her machine. Also the person who reads your document should have same fonts installed. This can be a bit of pain. Well, this is the older way, before Unicode existed.

So what is Unicode ?

Unicode is an encoding standard for characters, that gives a unique number to every single character in every single language. It is consistent across all platforms and operating systems. It means if I write something in Unicode and email it to a friend using Linux, he will be able to read my message, without having to install any special software. This is because most modern operating systems and software libraries have inbuilt support for Unicode. To find if your system is capable of showing Unicode stuff visit this link , you should see something meaningful.Let me tell you, thought Unicode is universally supported these days , you need at least one Unicode complaint font like ‘Mangal’ or ‘Arial Unicode’ installed . Generally such a font is bundled with operating system , very rarely need should arise to download them separately.Okay lets get to business. The following are a few well known software packages that perform transliteration.

Google Input Tools

By far, the most popular and convinient online transliteration package. Supports many Indian languages and has already been integrated into Google’s online product ecosystem. You can try it here .

There also exists an desktop version of the tool in form of Google Input Tools for Windows . These are basically IMEs (Input Method Editor) for Indian languages available for many Indian languages. Once installed an IME can be basically used with any program you want like messengers,browsers, text editors etc.


ITRANS is a well known old transliteration software. It works with special Indic fonts which the user has to download before using it. It is no longer under active development. The reason is UNICODE. But if you are using older system then you may want to have a look at it. ITRANS provides transliteration for Devanagari (Sanskrit/Hindi/Marathi), Tamil, Telugu, Kannada, Bengali, Gujarati and Gurmukhi. The very first thing you will want to look before using it is the ‘Transliteration Map’. It shows you which letters in English will produce what output in Indian languages. There is an online interface for ITRANS , which was not working at the time of writing.


JTRANS is a package similar to ITRANS , but has been written in javascript. So you can download it and use it offline.It also makes use of special fonts (instead of Unicode) for output. The online interface for JTRANS works really well and you should try it after installing required fonts.


You all will like this , because it supports Unicode. So you don’t have to have any special fonts installed . Just following this link . Now, there’s a small problem. I couldn’t get it working on IE , but it works just fine on FireFox. On more small problem I noticed was, I couldn’t see joined words properly.For example for ‘kra’ I was expecting the output क्र , but end up getting क् and र seperately. This problem seems to be of FireFox or rather of ‘FireFox for windows’. If you copy the hindi text for ‘kra’ and paste it in Microsoft Word you get correct letter! If you are interested to know how ‘joins’ are rendered in Indic languages read this. On this page search(Ctrl +F) for “half forms” of Devanagari letters and read the answer to the question. The FAQ is very interesting.

Indian Languages Type Pad

A cool transliteration software entirely written in javascript by Vishal Monpara. It offers transliteration in quite a few Indian languages. It integrates into your existing web applications effortlessly. Just add the following HTML to your webpage:

<input type="button" value="Type Hindi" 
onclick="win ='','Comment',
win.document.write('<script language=\\'javascript\\'>
var id=\\'TEXTAREAID\\';</script><script

You can also check out an online demo on his site here. The best part is that this is a free software.


Baraha is nice source for Transliteration tools. This site offers you a complete IDE for composing Indian Language documents , which can be downloaded here. I haven’t tried it out though. BarahaIME is very interesting, it is an Input Method Editor which works with Windows. Once you install it , you will see a small icon to right of your taskbar. Now start any editor or program . Click on taskbar icon and select the Indian language of your choice and just start typing into the editor/program. One important thing here, if you see some meaningless characters as you type change the font of the editor to a Unicode complaint one. IMEs are a great way of transliteration as it allows you to use multiple languages simultaneously. For example you can chat with someone in Hindi in one window and Kannada in another one.

Menu that appears on clicking on BarahaIME taskbar icon

Typing Indian language text directly into messenger using BarahaIME


iLeap is from CDAC ! You might have used it . I have tried the older version . Hope the newer versions support Unicode and don’t rely on special fonts.You can download iLeap from this site . Ileap is the only true ‘editor’ for Indic languages . I would really love to see Unicode support.If anyone has any news on this please write a comment.


Vachak is a Indian language Text to speech software . An impressive online demo is available here, which performs transliteration as well as text to speech ! Don’t miss this one.


I just found this tool from the internet . I haven’t used it, yet . If you know anything on this please inform me

More !

Implementing a transliterator is not very difficult. If you have descent knowledge of a programming language and have a descent transliteration map at hand, you can make your own transliterator (as I did sometime back). I prefer transliteration to onscreen keyboards.People tend to expect a lot from transliteration , then often confuse it with ‘translation’.I see transliteration as an effective method on inputting ‘Unicode text’ . It can work wonders if used in mobile phones ,handhelds and instant messengers. If you know of more such tools , do post a comment .

Running Linux on Windows Like Normal Programs

Using small Linux distro like Puppy Linux and open source emulator like QEMU, it is possible to run and stop Linux like normal windows programs. By creating virtual hard disks and using software like WinImage you can actually transfer data between Linux and Window. You can also create a virtual network between Windows and the guest OS for sharing and transferring files. And not to forget SAMBA in this context.

Screenshot of Puppy Linux

About Puppy Linux

1. Its small size 60-70 MB with full fledged GUI.
2. Rich collection of software like text editors, Mozilla, multimedia players ,ghostscript and support for networking.
3. Nice GUI tools for performing common and configuration tasks. This is something which windows users are very used to.
4. It even has a small web server and Tcl/Tk.

About QEMU

QEMU is an open source and fast emulator. The best thing about it is size (only 6MB).Though for now windows port is in alpha stage, it rocks. I like its simple command line interface for starting.

Getting Started

First download QEMU for Windows (Alpha)and unzip it to some directory.QEMU comes with a demonstration Linux distro image. Open the qemu-win.bat file, you see the following:

REM Start qemu on windows.
START qemu.exe -L . -m 128 -hda linux.img -enable-audio -localtime

Now download puppy Linux from any of its sites. I downloaded puppy-1.0.3-mozilla.iso which is about 62 MB in size. It has Mozilla as default browser. Copy it to same directory as qemu-win.bat file. Modify the qemu-win.bat file to:

REM Start qemu on windows.
@ECHO OFF START qemu.exe -L . -m 128 -hda linux.img -cdrom puppy-1.0.3-mozilla.iso -enable-audio -localtime -boot d -user-net

Hey! you have a full fledged Linux system running inside windows.

Starting Network

At the Puppy Linux shell type the following:

#dhcpcd eth0

Get the address for eth0 of emulator.I always get the address for eth0 as .On your windows machine you can get your ip using ipconfig (say it is Puppy Linux shell type:


If it is successful, start Mozilla and point it to some site on your IIS web server (Assuming you have one or else install one). In the screen shot you can see a site hosted on IIS server being accessed with Puppy Linux running Mozilla. By enabling directory browsing of the site you can even share files between both operating systems. Below is screenshot of Mozilla on Puppy displaying a page hosted by IIS on Windows 2003.

Enabling Sound

Enabling sound is also very easy.QEMU supports SB16 emulation .This is something I like about running Linux on QEMU , no problems with sound card .But Puppy could not detect sound card by itself. I used help documentation accompanying with puppy was of great help. Make sure you started QEMU with ‘audio’ option.

#cd /lib/modules/2.4.27/sound
#modprobe -v sb

You should see following entries in output of lsmod


I just put a simple audio file on my web server and pointed Mozilla to the site. From directory listing you can save the file and/or play it using gxine. Below is screenshot showing gxine playing a wave file. The sound may be quite squeaky though ;-)

Transferring Data using Virtual Hard disk Images

If you are a samba fan then you should definitely try installing and running samba with QEMU+PuppyLinux. Another nice way of sharing data between host and guest OS is using ‘disk images’. QEMU comes with a utility qemu-win.exe which can convert different types and sized virtual hard disks for use with Puppy Linux .I could successfully create qcow and raw formatted disk images. The advantage of qcow format is its small size which grows as you write to it. The advantage of raw format is that you can format it and use with a program like WinImage.Now comes the question of accessing this data .WinImage is an excellent program for this. It can even write(inject) files into a (raw formatted) virtual image files with FAT. Then I used FreeDOS floppy image and QEMU to format it to FAT16. Now you can use such a hardisk as ‘hda’ or ‘hdb’ of QEMU , mount it on puppy Linux and save data on it.

Doing More interesting things!

There are many more interesting things still you can try out. Firstly you can try out samba and experiment using OpenVPN(QEMU TAP version). There are many additional packages called dot-pups available for Pupply Linux here.I think combination of QEMU and Puppy Linux is just the perfect combination for small Linux that runs inside windows like normal programs. Moreover the executables for QEMU and Puppy Linux ISO occupy just around 70 MB of disk space and give you a full fledged Linux system with GUI and networking. This combination I think will be very helpful for those interesting in making small Linux distro ,students and hackers.

Puppy Linux download

Puppy DotPups


Puppy Home Site

QEMU for Windows TAP patch

QEMU with OpenVPN

How to use my album script on your website

I assume you have very basic knowledge of HTML. There are quite a few steps to be followed:

1] Download the zip archive from this location and unzip it to a folder.

2] Get all your images into the ‘hh’ folder. You will have to resize all images to 640*480 for displaying. Also thumbnails of 100*75 are required. Put the thumbnails into same directory with a different name. You can use GIMP to do the job of creating thumbnails and Picassa to resize images to 640*480.

3] Once you have thumbnails and images, the fun begins. Now you need to get a Google Map key. Visit this site and register to get your 86 charactor Google Map Key. Edit the photoalbum.html page and replace the #######… in first <script> tag with your google map id.

4] Open the images.xml file in notepad or any XML Editor. It is this file that contains all important information. To find latitude and longitude you can search for the place in wikimapia. Move the desired location to the center of the screen for maximum accuracy. On the address bar you should be able to see something like . You can get the coordinates from this query string. Here latitude of place is 17.991438 and longitude =73.027003 . If you see closely you can even get the zoom !(z=17). Enter one tag for each image . Make sure that you entered the right paths for images and thumbnails. An example file is given here:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="images.xsl"?>
<caption>Nice big mushrooms in the garden.</caption>
<tooltip>Somewhere here (I think!)</tooltip>

5] Do not enter any special charactors or line breaks into the text inside <caption> and <tooltip> tags. Right now the script is unable to handle it and produces errors.

6] Now upload all the files to your website , simple access the photoalbum.html file and your album should be working ! You can comment on this using email address specified in the FAQ section of the website or drop a comment.

The Internet of Things of 2002

Webpages from project to allow remote control of devices

I have wonderful memories of a primitive Internet of Things system we built in 2002. I had only begun to become acquainted with CGI programming and was fascinated to discover how real-world websites worked. CGI (Common Gateway Interface) enabled me to create C programs that can receive HTML form input and produce HTML. The possibilities appeared to be endless.

I intended to use my newly acquired talent to operate equipment at home because I was studying electronics engineering. I constructed a PoC with my pals and we published a paper about it. This was your 2002 Internet of Things (IoT). We were unfamiliar with the phrase “Internet of Things,” therefore we simply referred to our work as “Controlling Devices via Internet.”

Block diagram of the IoT PoC we created in 2002

One of the primary reasons my ventures into CGI programming were delayed was a lack of an HTTP server on my machine. Microsoft’s PWS (Personal Web Server) for Windows was roughly 60+ MB in size, which would have taken me weeks to download given my connection and constraints. I kept looking till I found Apache Server. It was only a 2 MB download, and I was able to access ‘localhost’ on my PC within couple of hours. The power of open source astounded me. I spent a significant amount of time building basic C/C++ scripts to generate dynamic webpages with CGI. It also made me love HTML/CSS and I developed good expertise on the frontend side of things as well. It was almost as if I had a new superpower, and it felt great!

Tcl/Tk - The swiss knife of scripting and GUI

A simple clock I made using Tck/Tk

This occurred during my second year of engineering. I used to like spending time in the library reading books on ‘off-topic’ subjects. People thought it was unusual that I spent the most of my time reading computer and programming books as an electronics engineer. One afternoon, the book ‘Tcl and the Tk Toolkit‘ by John K. Ousterhout piqued my interest! Nobody seemed to care about Tcl/Tk, and the book was as good as new and had never been borrowed. That was a lucky day for me. Finally, I had discovered what I had been seeking for since I decided to study GUI programming.

I built quite complicated GUI apps with few lines of code using Tcl and Tk, which would operate on both Windows and Linux. The interpreter was only about 5 MB in size, which was incredible. Consider a feature, and this stack had it, such as :

  • the ability to create windows
  • drawing shapes
  • common controls
  • canvas
  • grid system
  • sockets and networking
  • much more

Not only that, but there were tools that could combine your script and interpreter into a single distributable binary. I had a great time working with Tcl/Tk. I took it up in a matter of weeks and began building pretty impressive-looking GUI apps to show off to my friends. Many of my pals were surprised when they saw! They used to ask whether I built such graphical user interface applications in VC++ (and I would grin!)

This is a sample application I built to learn about controls, events and packing semantics in Tcl/Tk:
learn about controls, events and packing semantics

Here is an attempt at creating a webserver with Tcl/Tk:

A program to calculate integrals using Simposon’s Rule:
 calculate integrals using Simposon's Rule

No shortcuts for mastering OOP and GUI programming !

One of my prized possessions.

In my prior post, I described my daring quest of gaining admission to the Electronics Engineering program. We had to stay at my father’s friend’s house because the admissions procedure had been postponed until the next day. There, I discovered an excellent C++ book called C++ Program Design by Cohoon and Davidson.

There were several C++ books available on the market. What set it apart was that it came with a CD containing a library called EzWindows that included object oriented APIs for creating simple GUI programs for Windows. After my unsuccessful attempts at learning VC++ , I had been looking for literature to learn OOP and GUI programming. This book provided both. I didn’t waste any time in buying this book.

The authors did an excellent job of introducing newcomers to OOP. The EzWindows library aided me in comprehending real-world applications of OOP and creating some enjoyable projects. I wish I had discovered this book sooner.

The library itself was rather small. You could draw simple shapes and text. Some mouse events were supported, and later in the book there was a bug squashing game. The only thing it lacked was the ability to accept user input via a graphical user interface. Using the examples in the book, I constructed a maze traversal program that looked like this.

A simple maze traversal program written by me using EzWindows Library

It was basically invoked from the command line. It read data from a text file and navigated a graphical maze. It was a lot of fun!! The book helped me comprehend OOP and enhanced my knowledge of C++; it was one of the greatest books I’ve ever read!

Results, rain and a half hearted decision !


My 12th grade results were announced. I had always wanted to pursue computer engineering, but my PCM (Physics-Chemistry-Maths) scores were not up to par (though they weren’t horrible). There was a lot of doubt and anxiety. My father was an optimist , h e always believed that I will make it to Computer Engineering. If I had applied to colleges outside Mumbai, I would have had a better chance of getting into Computer Engineering. My parents were concerned, we kept discussing every possibility, calling relatives and asking for advice from people.

The big day arrived, when the engineering entrance forms were made available. The form packet included a booklet with general information on various colleges at Mumbai University, and also prior cutoff dates for various courses. The most sought-after course was computers engineering, and the competition was intense. I had very little chance of getting into Computer Engineering, at least at Mumbai University. But then there was a twist, for some reason, the University had a 20-80 format. For Round 1, 20% of all college seats were available. If you applied and were allotted a seat, you could not apply for Round 2. This appeared to be a decent bet. We decided to be realistic, and instead of applying for the best courses at the top colleges, we applied for those that were somewhat lower on the list. After much consideration, I chose to maintain ‘Electronics Engineer’ as my secondary choice. So the forms for Round 1 were filled and submitted.

When the results of the allocation were released, I was offered the choice of enrolling in the ‘Electronics Engineering’ program at Datta Meghe College of Engineering. The best thing was that the college was close to my home, I could walk. The not so good part was that I did not get into ‘Computer Engineering.’ I decided to seize the opportunity.

I recall well the day me and my dad went to VJTI to complete my admissions procedure. Most graduates from the 2004 class will never forget that day. That day it rained like crazy. People had to walk through waist-high water to get to the admission office. Many people were unable to reach. Due to severe rains, the authorities postponed the process until the next day. Everyone’s issue was that they couldn’t go home due of the flooding. The fortunate ones had a friend or relative in the neighborhood. My father and I went to his friend’s house. We brought clothing and food before checking in.

The next day was considerably better after a rough night. The weather had cleared, and everyone was greeted by bright sunshine. We went to the center, I reconfirmed that I was option for Electronics Engineering. I was reminded that I wont be able to participate in second round. We paid the demand draft, got some sweets, and went back home.

The decision I made that day was one of the best I’d ever made in my life. I was drawn to Electronics Engineering since the course covered computer principles like no other, from transistors to gates to programmable ICs and devices. I can confidently state that my knowledge of electronics has aided me in developing a solid grasp of computer hardware and software. This was the start of a new adventure in which I learnt a lot and met a lot of amazing mentors!

The good old days of dial-up !!

Ever since my father got me a computer, I’ve been nagging him to get me an internet connection. Back then, the internet was considered a ‘luxury item’ rather than a need. The only internet service available was dial-up. This entailed paying for internet and phone bills, which were not insignificant expenses for a middle-class Indian family in 1999. But I managed to relate the internet access to my studies and persuade my parents to get it for me.

It was the 1999 monsoon season. I was in my first year of junior college at the time (11th grade). I recall my father and I riding on our scooter to Thane to get a modem. We had opted for an external model, simply because it had more LEDs, looked cooler and was easy to play around with. We went to a shop and bought the Dlink’s DFM-560E modem. I was so delighted and happy that I wanted to start browsing right away. But there were two critical actions I needed to do before I could use the modem:

  • Run a telephone cable from the hall to the room where my PC was kept.
  • Purchase an internet plan/dial-up kit.

I suppose it took a week to obtain the kit and complete the wiring. I was up till 2 a.m. getting everything set up. My uncle, who used to live next door, had also shown up for assistance. As things were being set up, there was a lot of excitement in our home. VSNL (now known as Tata Communications) was our Internet Service Provider . After many trials and errors, we were able to see the ‘connected’ status on our monitor. I believe the first website I viewed was There was a sense of accomplishment and joy all around. Our family had finally entered the ‘Internet Age’.

The next stage was for my parents to develop a ‘Internet Access Policy.’ Back then the internet was notorious among parents for reasons such as:

  • You can catch viruses through the internet
  • The risk of children getting engaged with bad company.
  • Horror stories about people receiving absurdly high landline bills.
  • Hackers breaking into your system
  • ..and many more

After a lot of debate and discussion, our ‘Internet Access Policy’ was formulated. This is how it looked like:

  • I was only permitted to use the internet for 1-2 hours on Fridays.
  • If my use surpassed our monthly budget, I had to stop using the internet.
  • I could only use the internet after 10 p.m.
  • No interaction with strangers or creating online friends was allowed.

I used to build a list of fascinating websites I wanted to visit each week. On Fridays, I used to spend one hour downloading these sites for offline reading. Disabling photos and media helped webpages load much faster, which was great for many sites. Emails were something I had to read for 10-15 minutes because they were not available offline. The two most popular browsers at the time were Internet Explorer and Netscape Navigator. It was still amazing how much data you could download with a 56Kbps connection. After Friday’s session, I had enough material to read for the rest of the week. Apart from educational purposes, there wasn’t much you could do with the internet back then. If I needed to talk to a buddy, I would call them on my landline because it was the cheaper and faster method to connect. Back then, social networking was only a developing concept.

For me, the internet was a knowledge multiplier. Finally, I didn’t have to restrict my extracurricular learnings to expensive books and magazines. There always was more stuff than I could read !