25 March 2014

Being comfortable while seated at your workstation

I've seen many people carrying the strict discipline they learnt in school to office too. In an environment where they have to be seated for hours at an end, they try their best to not complain and adjust. Many end up seriously damaging their health. A friend's sister ended up requiring spinal surgery because she tried her best to sit straight and stiff while working; ignoring her back pain all the while.

Some chairs are designed for people with long thighs. People with short thighs won't be able to adjust to it (and vice versa). Good news is, chairs can be adjusted. But I rarely see people doing it. I did.

Got the armrests removed and the back of the chair tightened and phew! It was such a relief to be able to sit comfortably!

More on adjustments: http://www.ccohs.ca/oshanswers/ergonomics/office/chair_adjusting.html

20 March 2014

My Creations

My story of being a programmer has a lot of twists and turns. The initial struggle to understand syntax and almost failing my computer science test; my dear teacher motivating me, my uncle sharing a computer for me to work on; me programming games on it (because the computer didn't have any games), creating and learning much more than my peers and eventually being one of the top programmers in class and in 9th grade, during a predicting game at my Prefects picnic, writing on a sheet of paper that 10 years later I'd be in the company of software engineers. My parents and relatives however didn't understand my interest in programming (2002 was a panic year when software people were losing jobs) and pushed me to do Mech engineering. I continued programming even during my engineering (winning a state level hobby project in the process and surprising my Mech seniors when they found me reading computer science books in the library). Landed my first job at an international Interaction Design startup as software developer even before I stepped out of college, went ahead to do my post-graduation in software and exactly in the 10th year following my prefects picnic, joined a company that built hardware and software for the Indian Defence Forces and had my aim fulfilled.

Some of my hobby projects

Most of my initial programs were created on a 286 computer which didn't have Windows installed. Only MS-DOS. Max speed of the computer: 20MHz. Hard disk capacity: 30MB :-) It was only after my Engineering course that I got an internet connection at home, so the below programs are a result of hard-work and self-study of API's and documentation.

Kids of 3rd and 4th grade used to LOVE this game. I guess it's because of the simplicity and the funny sounds I programmed into it. This was the first game I programmed (in GW-BASIC) when I was in 9th grade, and my little brother was crazy after it. He even beat my highscore!

A game with ten levels of increasing difficulty and challenges. Created in 10th grade. Was introduced to the term "cheat codes" at this point of time, and introduced this into the game.

I used to create mazes on paper, and decided to program one too. Was a daunting task setting up the arrays on large sheets of paper I stuck together and then replicating the same on the computer. The maze was programmed with portals and wells (which you might fall into and die). It was also divided into 4 sections which made it very difficult to solve, because you had to remember the previous screens to find your way. My best friend tried for three hours, and said he couldn't solve it (to date, I'm the only one who has solved it).

This was one game I really wanted to program. Had played it many years back on a cousin's computer, and wanted to play it at home too, so just created it myself. Wasn't familiar with Q-BASIC graphics at that time, so used ASCII characters. It's a game with a digger machine digging through mud, collecting diamonds, monsters trying to destroy the machine and the machine being able to shoot at the monsters or drop sacks of money on them to kill them. Then collecting the destroyed sacks to get more ammo.
Had created an initial version and then improved upon it.

Calculator program
Okay, this one was too simple, but it was programmed to be user friendly by allowing the user to navigate from one key to another using the arrow keys and by providing a square root option (which I'm surprised that many calculators strangely still don't provide).

Mock antivirus program
Well you'd recollect I was using my uncle's computer, and I wanted to pull a prank on him. I created an antivirus interface which was pretty similar to the real MSAV antivirus interface of those days. The program pretends to scan the computer and pops up an alert that it found a boot sector virus which can't be removed. Uncle actually believed it! :)

Vein: An MS-DOS OS interface, like Windows
Navigating through the commandline is difficult for people. My family found it tough to use the PC because it didn't have Windows and the MS-DOS interface was too geeky for them. So I created an interface (while in 11th grade) for interacting with MS-DOS. Pretty much like how the Windows graphical interface was created by Microsoft.

Digger forever
Had wanted to make my Digger game closer to the actual game I had played at my cousin's house (now available here), so while doing my engineering, when the ISTE student chapter organized a state level hobby project competition, I borrowed my room-mate's computer for two weeks and created Digger with BASIC graphics (presented it along with my other games). And guess what? I won the competition with a Rs.2000 cash prize! Roommate got a generous treat and seniors were all-praise :) The Mechanical engineering student who won a competition by programming games!
[update] Just found the original of the printout my very-happy-seniors had put up on the college and hostel notice board after I won the prize (S.R.C is the name of their club).

Message decoder program
Converting text from English to a coded language and vice versa being slow, I wrote a program for it. Also kept it flexible for it to be able to accept a new code sequence too.

Mechanical force visualization software
A Civil engineering lecturer at my college asked me if I could create for him, a program which would show a 2D representation of the normal and tangential forces on a beam. He also wanted a simple graph to show the force distribution. By this time, I had derived 3D projection equations on my own (I didn't know this would be available on the internet, so I had actually drawn projections on paper and derived the equation by using whatever I learnt in trigonometry), so I took my lecturer completely by surprise by using the graphics of C (using the Turbo C compiler) and created the beam in 3D, as an application with full-fledged menus and an interactive graph. You can actually rotate the beam in 3D using arrow keys, feed in various values using textfields (all UI elements were manually programmed) and also load/save the values. When I look at the program today, I find it hard to believe that I actually programmed it at that age!

Had wanted to make a game like Dangerous Dave, and I began with Ben. But this program was left incomplete, as BASIC does not have the concept of threads, and on adding a monster in the second screen, gameplay became too slow. Was able to get over the tough part of programming multi-key input to make Ben jump around.

Those were my student days. As a professional, I've learnt a lot more.
I've also engaged in creating a few scripts here and there to ease my work.

Greasemonkey for auto-clicking a web-page

A certain page required clicking a link every time I visited the page. So I thought I'd automate the process with this code snippet. 

var element = document.getElementsByTagName("a"); // get element by tag namevar theEvent = document.createEvent("MouseEvent");
theEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 30, 79, false, false, false, false, 0, null);
//var element = document.getElementById('link');

Recursing directories

Wanted to  be able to move recursively through directories to automatically delete those annoying Thumbs.db and desktop.ini files, so wrote a small python script for it:

After writing it, I discovered that the functionality was already available in Python via the walk command ... *sigh* ... anyway at least there's the joy of creating a program on my own and being able to tweak it as I wish!

Resting my eyes

What's the point of knowing VC++ if you aren't using it to your advantage? I borrowed some open source code for a program which sits in the system tray in Windows, and modified it to start at logon and pop up a message at a specified interval of time, alerting a person to rest their eyes for 5 min. Strained-eyed friends and I found this program to be a boon. Of course when I found Eye Leo, I switched to it immediately.

Popup Destroyer

A poor security setting created by a certain someone, made an "Authentication required" popup appear whenever I opened a new page on my browser. The user just had to press Esc to make the popup go away and it was very annoying. So I wrote a sentinel program in VC++ to run in the background, scanning all window titles for the "Authentication required" string. When it found one, it'd immediately issue the Esc keypress command to the window automatically and the window would get closed. I used to enjoy watching those windows disappear while I continued with my work happily :-).

Volunteering website

Our volunteering team in Tata Power SED needed a website and we decided to create it ourselves. I created an interactive prototype in 3 days and soon other volunteers pitched in to improve it further. We made good use of free and open source code available on the internet.

This I created for a friend in data analytics, who needed to hash specific columns in CSV files.
More about it here.


At one of my previous workplaces, they decided to buy evening snacks everyday. Our office assistant used to go around asking a different employee everyday what snack to buy. Since this became a bit annoying for employees to choose (and others to grumble about the choice), I decided to automate it :-) I created a Java program which our office assistant could use, which would randomly select a snack and display it on the screen. A 'recent snacks' list avoided redundancy and if he rejected a snack, he'd be shown another random option. After a while, I noticed he wasn't so keen on using it. I investigated and found that he didn't understand the concept of brackets and commas in the JSON file which contained the snacks list :-) So I converted it into a CSV which he could open and edit in MS Excel. Obviously everyone else was amused at an "AI" selecting their snacks for them and when I was leaving the company for higher studies, the COO told me "Navin, when we write a story about our startup, this is definitely going to be one of the anecdotes in it; that we had trouble choosing snacks everyday and one of our engineers wrote a program to solve it!".

Bachelors of Engineering project (2006)

I wanted to build a robot, but there was not a soul who was willing to help us or sponsor it. So my enterprising team members and I decided to build it from scratch. We designed the robot arm in AutoCAD, created prototypes with thermocol, did the filing, drilling and cutting on our own in the workshop and built a working model which could be controlled with conducting copper strips on gloves. The arm was designed to be a stand-alone detachable arm which could be removed from the main structure and wrapped onto a human arm using velcro, becoming a bionic arm. Using just wrist movements, the 'jaw' would open and close. This was designed to be used by persons affected with leprosy. Our college appreciated the hard work and our applications for sponsorship were the first in our college to be accepted by the Karnataka State Council for Science and Technology. They fully funded our project and invited us to exhibit our project in Gulbarga at the KSCST exhibition.

Evolutionary algorithm

Example I built, to showcase how evolutionary algorithms can solve highly multidimensional problems in a very short amount of time.

There's more of these "embodied" robots I've created for my thesis, which I'll be publishing here after my work is published at a conference or journal.

10 March 2014

Setting the fastdial page as your homepage

I've always found it more productive to have the fastdial (it's a Firefox addon like speeddial of Opera) page open for me whenever I open my browser.

The latest version though, didn't show fastdial as the homepage. So a bit of digging up got me this:


Use the above link as your homepage, set Firefox to open the homepage when you open the browser and set Fastdial to show up when you open a new tab, and you'll have your most-used websites at your fingertips with fastdial.

02 March 2014

A minimalist interface

Downloaded and started using the GitHub client for Windows today and noticed that they had designed the application to have a minimalist interface. So beautifully designed!

Creating a minimalist interface isn't easy though. Takes a lot of planning and guts to put on the screen nothing more than what is actually required. I'm a fan already :)

Here's Martin Fowler's views on it and the KISS principle which support it. GitHub client's interface also reminded me of the clever no-click interface created by the institute for interactive research.

Unite. A hobby project

Unite, is a project I began working on, when I wanted to re-learn web app programming. The project is designed to have a highly customizable front-end, a robust back-end and either a relational or a graph database. The project is hosted on GitHub under GPL v3. This is also meant to serve as a project that will give me a deeper understanding of using Git, continuous integration (Jenkins), Issue tracking (Trac), automated testing, automated code coverage checking, build scripting (Gradle), automated bug finding and deployment (Phew! Big target to achieve with the limited time I get everyday). This page captures the progress of the project.

Setting up the basics

Setting up a new project on GitHub was a breeze. Once done, I cloned the repository onto my local machine and using SmartGit, created an authentication token, the folder structures, spent an awful lot of time learning Gradle by myself and decided to use Gradle with Netbeans (which has Gradle support built-in) because the Eclipse plugin ended up giving me some errors during build. Setting up a continuous integration build right from the start was a practice I wanted to follow, so after installing Jenkins (tried Hudson too. It's good, but I liked Jenkins' interface better), it's plugins and successfully figuring out how to trigger a build on Git commit (this is a better approach than making Jenkins poll to check for code changes), the project was ready for some real coding.

D3.js as a general purpose data visualization library on the web

What would one do when one wants to use JavaScript to graphically display some data or statistics on a web-page? Use a library of course. I saw a lot of libraries, but was shocked at what d3.js had to offer. Just have a look at these:

Amazing! The initiators are Michael Bostock, Jeffrey Heer, Vadim Ogievetsky, who created d3.js (BSD license) based on the experience they had from the stepping stones of other similar projects that didn't work out very well.

It takes a while to figure out how to use d3. If you have a good understanding of JavaScript, you can start off right away. If not, the concepts of anonymous functions and closures will help you learn. Most of the impressive functionality can be implemented with just the d3.js file (319kB). A more compressed version of the file d3.min.js (144kB) is also available. More advanced functions are available in the supporting script files of d3.

A novice would find it surprising, the way d3.js works. By selecting elements of the DOM before they're even created. By passing variables like "d" and "i" internally, which don't seem to be declared anywhere.

But that's the challenge that makes it worth learning! D3 is a tool with which you can use on any area of the DOM. You can create any kind of visualization you want.

To make d3.js simpler, there are encapsulating libraries like nvd3, c3, cubism and rickshaw.

Went through the source code of d3 as usual, and was completely taken aback when I saw they've used the actual pi, phi and lambda symbols as variable names! Decided to ask my community, and here's what they had to say about it. Although it looks fancy, it's better to stick to variable names rather than symbols. Psst...if you want to generate pi on your screen, make sure the num lock on your keyboard is on; then keep the alt key pressed and type 227 on the num pad and you'll get the pi symbol like this ( π ). I pasted it in notepad, and it didn't turn into a junk character. Cool, isn't it?!
Jeff Atwood had an article on the use of unicode too (the 'entity' word is to be replaced by a heart symbol).

After dabbling with d3.js for about a week, I created an ajax program to query a servlet for data and display the retrieved data on a d3 graph. Worked like a charm!

A nice source for learning are the tutorials from the main website, practically trying it out a little, a free book and if that isn't enough, more than a thousand examples with sources, for you to refer. Definitely a work of art!

01 March 2014

Keeping those wires all neatly wrapped up (and a point on wireless electricity)

Well, as software people, we also have to deal with hardware issues :)
One of them, is getting wires in place. While there are various clever ways to do it, the one that solves the problem of keeping earphones nicely and inexpensively wrapped up, is this one.

This could have been a time and age where we would not have had to deal with wires. It'd have been a reality if Tesla's Tower of Power wasn't pulled down by economic problems and a short-cut, cost-effective solution to communication by Marconi.
More on the Wardenclyffe Tower here: http://en.wikipedia.org/wiki/Wardenclyffe_Tower
Same story told in a damn-interesting way :-)  http://www.damninteresting.com/teslas-tower-of-power/

It intrigues me, the way some people develop an intuitive understanding of a subject. Tesla understanding the working of electricity, in this case. Einstein, understanding the concept of relativity. Newton and gravity.

What also intrigues me is the way commerce isn't designed to produce the best possible outcome. Corporates always go for the short-term approach which makes money (and hence sustains life), rather than the long-term approach which could have sustained life in a much better way. A concept called Hyperbolic Discounting.

Looking forward to a truly wireless future.