Who are programmers?

If I have to define programmers by one word, and one word only, I’d use “lazy”
Programmers out there, don’t get triggered yet. Give a fellow programmer a chance to explain himself.

It all began when a friend wanted to convert several JPG files into a PDF document. He was going to upload them into Microsoft Word, and then save as a PDF document. Somewhere deep inside, I didn’t like the idea. I offered to do that using Linux magic.

Imagemagick is a command line tool to do cool stuff with images. The command to convert image from one format to another is simple.

   convert lena.png lena.jpg

To convert several files into a single pdf, the command is,

   convert *.jpg combined.pdf

But there was a problem. Have a look at it yourself.

Screenshot from 2017-06-07 14-34-55.png

Two pages in the PDF were bigger than the rest. I have no clue why Imagemagick is doing that. Maybe a bug(feature ;p ), but that’s another story.

I needed to find a solution. What started as a simple problem, became an addiction. It took me about an hour to finally figure it out… Here is a screenshot which gives you an idea of what I had to go through. Note the number of tabs.

Screenshot from 2017-06-07 02-16-50.png

Unfortunately that wasn’t the happy ending to the story. I had 13 images named 1.jpg to 13.jpg. When Linux lists them, it lists them in a weird way.

Screenshot from 2017-06-06 23-49-38

10, 11, 12, 13 are listed before 1, 2, 3, 4… Imagemagic uses the same ordering as “ls”, and so, the pdf is combined in wrong order.

I searched for a way to sort the files according to human-readable way – and found this gem.

   ls -1 | sort -h

Screenshot from 2017-06-06 23-50-01

So now, I have to somehow incorporate that into the convert command. From prior knowledge(thanks to having used openCV in linux), I know that `(backtick) can be used for this. Here is the command that I finally used to convert and combine the pdf in proper order.

   convert `ls -1 | sort -h` \
    -density 72x72 -units PixelsPerInch \
    -resize 3508x2096 -repage 3508x2096 combined.pdf

Screenshot from 2017-06-07 18-38-12.png

Basically whatever you place inside backtick’s will be executed before the rest. And we exploit this in the previous command.

This story defines a programmer perfectly.

Programmers are lazy, and so, we work on automating things.

This might sometimes end up in more work than just doing it manually. I could have found several online websites to convert JPG’s to multi-page PDF. But still, we do it.

We do it(even if takes longer) because we like to do it.

However, code which becomes completely obsolete with small changes in the problem statement is useless. We don’t want to write new code when a problem statement is changed slightly,  so we expect the possible changes in the client’s requirement and write code that can adapt to these changes easily.

We write code that is scalable – in all senses.

For example, When I found that the pages in PDF were in wrong order, I could have simply renamed files to a,b,c… since I had only 13 files. The convert command would have combined in the correct order. But what if I need to combine 1000 files later? The solution breaks.. and so, its not a good solution.

If you are a programmer, you can probably relate to this.
If you aren’t, well, maybe from now on you’ll appreciate our “geekiness” ;p

Using computers for their original purpose.

Well, computers were invented to perform mundane tasks, so everyone who knows how to use a computer should know how do automate file and folder operations right?

This is your opportunity to pick up a few tricks that will give you a boost towards being the top-geek.

When I need to automate something, I usually run some scripts. These are small pieces of code written in some language which will automate the task for me.

Some common tools that I use, that enable me are,

  • Regex
  • Basic Python
  • Bash
  • Linux applications
  • Stackoverflow, Stackexchange sites, and in general, google.


Regex  stands for Regular Expressions. Have you ever ended up in a situation where you wanted to search for text which is in some complicated, but regular pattern?

Regex allows you to do so.  Its just amazing.

You want to try it out – Install any text editor that supports regex – My personal favourite – Sublime Text.




Python is a powerful programming language, but its also extremely easy to learn. Its very difficult to find powerful technology without a steep learning curve, but this one does it very well.

Some of the automation that I have done with python are,

  • downloading of webpages and other resources from web, including mails
  • file and folder operations like renaming etc.
  • operations on date and time with powerful additional modules
  • automate and track key presses and mouse clicks
  • doing all of the above and more parallelly
  • work with images – resizing, converting colors etc.

Python by itself, comes with huge possibilities, but people have worked on their own ideas, which you can find and use. You can do this by using a tool called pip.

If you are a complete beginner to programming, you can learn python the easy way, over here,



After having a look at python, you might feel that bash shell is the more difficult way of doing the same thing in python.

While that may be true, learning bash, allows you to understand the inner workings of linux, and will help you on your way to becoming a tech-guru

So just suck it up and learn bash. Or be the guy who said, “I dont need linux – I use <insert_language_here> in Windows” – and suffer the wrath of the linux gods when you finally realize that the whole world runs on linux.

Linux Applications

Sometimes what might take you and me hours to write – is already written, and ready to be used – for free.

Just make a quick search for “awesome command line apps“. You’ll find a ton of cool stuff.

Google and StackExchange

And my previous sentence is the real reason why you should know how to “search and learn” on the internet.

Coz tech people are too busy solving real problems, and are unable to write documentation for noobs like us.

But we have something better – question and answer platforms like stackexchange has more information than any book, website, video you’ll ever come across. The only difference is that its organizational structure is aimed at people searching for answers to a particular problem, and not for people looking to learn something new

So get moving, and start working on something. Try and download cat pictures from google images. Or youtube videos. Find out the most used word in this blog post or rank the words by their usage.



The concept of Joint-Probability


As a mathematical construct, probability is one of the few which feels intuitive. It’s not like Linear Algebra, which requires some imagination to think in n-dimensional spaces.

But… Add another word in front of it, and you get something that seems to make no sense.

Yup. I took a Probability and Random Processes course in my undergrad, and Joint-Probability was the most difficult concept to wrap my head around.


Simply put, joint probability defines the probability of simultaneous occurrence of two things.

Honestly, the best way to explain joint-probability is through an example.

The big bang theory, Season 5, Episode 5

Someone has to go with the telescope as a payload specialist, and guess who that someone is..
Mohammed Li

The genius Sheldon Cooper, has a simple logic behind his guess(maybe too simple).

He guessed Mohammed Li by using probability. He states that it is common knowledge that Mohammed is the most common first name, and Li is the most common last name.

Thus, combining the two, he got the most common… hey.. wait a second.. Mohammed Li is a almost impossible name. It is definitely not the most common name.

Why do people face difficulty with it then??

It’s now clear as to what Joint-Probability is and does.

The bigger question is, how is it that undergrad students don’t understand a simple concept like this.

Well, in my course, probability  was taught as a measure. From the set-theoretic definitions and axioms of probability.

Thus, Joint-Probability was introduced using the Joint CDF(Cumulative Distribution Function), and its derivative was the Joint Probability Density.

Thus, the math was conveyed, but the meaning was not.


I love The Big Bang Theory, and this post was not made with an intent to pin-point any negatives about the show.

What is sudo?

Sudo is Dangerous!

sudo is a command that people use a lot – without knowing what its for. But sudo is not to be trifled with – It can destroy your system in a multitude of ways.

For example, “sudo rm -rf  /*” tells your system to delete all files. And it will obediently do it.

The only way to protect yourself from getting into such situations is to understand what sudo is, so that you don’t use sudo needlessly.

xkcd – Look it up, if you don’t know what it is

Continue reading