I love Onam. It is an amazing festival which all Keralites celeberates without caste and religion. Onam happens when the weather is at it’s best. Right after monsoon rains, whole Kerala turns colorful to welcome Onam. This time is a celeberation for photography lovers. I made the below image on the Onam day. The mix includes, Canon 7D MKII, 100-400L and flash in high speed sync. This image was made at a stunning location named Vallikkunnu,

We got Leh’d!

Feel like getting out of here? I am game- let me grab the bike keys and a map of Himalayas. Why Himalayas? Well, because Himalayas has always fascinated me. I have read countless books on Himalayan travel and nerve cracking experiences people had. This July (26th Jun 2017 to 5th July 2017), Anju and I took the courage and went for a Himalayan trip on a motorcycle. The trip was adventurous and fun filled.

Accessing nested keys from a map in Elixir

Erlang VM is a powerful pattern matching system. Pattern matching comes very handy when you want to access nested fields in a map.

Recently at work, I had to parse a large JSON and extract value of a key. This post shows how you can use pattern matching to extract deeply nested values from a JSON.

oh my jackson!

Jackson just made my day! Today, I had to make some changes to one of our API. The change was minor so I have added additional fields into my JSON response. I have also kept the old fields just to make the existing clients happy. During testing, I figured out that the change breaks existing clients. I was surprised! The error was, org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field “image” (Class Promotion), not marked as ignorable

Upgrading blog to hugo

I always wanted to try out Hugo but never got a chance to do it. I spent some time today and migrated my Octopress blog to Hugo. So far, I am liking it. I didn’t find a theme which matches my expectations, but the default one and few others are good enough to get started.

Bringing business ideas to live in 3 months

Early July, we started working with 2 ex-yahoo friends who had a nice product idea that they wanted to make it live. They had some screen designs on paper and clear cut vision on what the product should look like. We started with the development, post a week of ideation and technical spikes, and guess what, we had MVP ready for a limited user release in less than 9 weeks and a full production version by the end of October.

Function strdup implicitly converted to pointer

I was trying to make a debian package for libvarnam. Lot of work went into making the package ready. Debian has very strict rules about how the packaging should be done. Debian also marks few errors as fatal and which may require a code change to fix it. One of the errors I faced was the following: Our automated build log filter detected the problem(s) above that will likely cause your package to segfault on architectures where the size of a pointer is greater than the size of an integer, such as ia64 and amd64.

document.ready() handler not getting fired Rails4

Rails4 uses a gem called turbolinks which makes following links on the web application faster. This gem is added to the Gemfile by default when a new rails project is initialized. However, there are few side effects this can cause. Consider the following JS, added into app/assets/javascripts/projects.js: $(function () { $('#startDate').datetimepicker({ pickTime: false }); }); This looks alright, but won’t work as expected. When rails navigates to the page following a link, turbolink comes into picture and makes it faster by caching the JS contents.

Hiding menu when clicking outside - AngularJS

Assume you have a menu which looks like the following: <div class="right-menu" ng-click="toggleMenu($event);"> <img src="img/RightMenuIcon.png" alt="" /> </div> <div ng-show="menuOpened" class="menu-dropdown-right"> <ul> <li ng-hide="loggedIn" class="class"><a href="#/authenticate">Login</a> </li> <li ng-show="loggedIn" ng-click="logOut()"><a href="#">Logout</a> </li> </ul> </div> When the div gets a click event, angular calls toggleMenu which toggles the menuOpened variable. Changing the value of this variable in turn makes the div show/hide. To hide the menu when clicking outside of the div, we add a onclick handler to window object which checks the menuOpened variable and updates it if the menu is visible.

how to get lintian warnings when using ubuntu

Recently, I started to package libvarnam for Debian. I followed the debian packaging guidelines and successfully created a package. I am using Ubuntu instead of Debian to do the packaging. Since Ubuntu is based on Debian, packaging also has the same procedure. Debian requires all the packages to be lintian clean. Lintian is a command line utility which checks for errors and standards violations in the package files. My package was lintian clean and I have uploaded it into the debian mentors page seeking for sponsors.

Channels in libuv

go programming language provides a very powerful synchronization mechanism called channels. Channels simplifies communication between threads and makes it very easy to send and receive data from go routines. I always missed such functionalities when using libuv. libuv has uv async_send, but it can be used only to wakeup the event loop. In this post, we will implement channels in C using libuv. The idea is to implement a channel so that user can use it without worrying about manually doing the synchronization.

Building static and shared libraries using CMake

Recently in libvarnam, I had to build a static and shared library from the same source files. This was much harder before CMake 2.8. From CMake 2.8.8, CMake has support for Object library which made it very simple. Basic idea is to use add_library with OBJECT type. CMake will compile all the source files provided in this target and makes the object files for it. It won’t create a temporary static library with all these object files.

How to use individual lines pulled from stdin in the middle of a command when using xargs

xargs is very powerful commandline utility. Here is what Wikipedia says about xargs xargs is a command on Unix and most Unix-like operating systems used to build and execute command lines from standard input Most common use of xargs would be to do something like, find . -type f -print0 | xargs -0 rm Let us assume that you have a file with list of files to be downloaded from a website.

How to upload files when testing using Selenium Webdriver

You can use the following code to set a file path to the file upload control. WebElement file = driver.findElement(By.id("control_id")); file.sendKeys("/full/path/to/file"); You need to pass full path to the sendKeys() for it to work. Otherwise sendKeys() fails silently.

Is Thread.Sleep() evil?

If you search for this topic, you will find lots of information and many of them claiming Thread.Sleep() is evil. However, I think this evilness is mostly dependent on which context Thread.Sleep() is used. You might have seen code like the below one. while (!exit) { DoWork(); Thread.Sleep(10000); } This code example does some work and sleeps for 1 minute before does the job again. This simple example has some potential issues.

Working with native code easily in C# with the help of C++/CLI

.NET comes with pretty good interoperability options which would enable unmanaged code to be used from a managed environment. In C#, to call a function which is available in a DLL, PInvoke (Platform invocation service) can be used. Here is what MSDN says. Platform Invocation Services (PInvoke) allows managed code to call unmanaged functions that are implemented in a DLL. This is very helpful when you need to call some system functions from your C# application.

Simple, generic and dynamically allocated array in C

C is a very good language. I have been using for quite some time for my opensource project. The flexibility C offers is really good. But sometimes, lack of simple datastructures like a dynamically growing array will slow down the programmer. There are tons of implementation available online, but most of them are overcomplicated, got lot of dependencies or tough to understand and incorporate with your application. In this post, I present a simple array which grows dynamically, reuses the memory, supports any pointer type and easy to copy to your code base.

Simple egg timer on Linux for Pomodoro technique

Recently I have started evaluating the Pomodoro Technique which I found quite interesting. I am still evaluating the technique and not yet concluded on whether I should continue using it. To implement pomodoro technique, you need a kitchen timer or egg timer. Since I use pomodoro for my programming work, I obviously don’t want to use a physical timer. I couldn’t find a decent timer for linux especially one that works well with Xfce.

Circular linked list – An implementation using C#

In this post, I will explain about creating a circular doubly linked list using C#. .NET framework provides a doubly linked list implementation in System.Collections.Generic.LinkedListclass . But this class is not providing the behavior of a circular linked list and it is very tough to extend for supporting circular linked list requirements. In a normal doubly linked list, each node will have a link to its previous and next nodes. In a circular doubly linked list, tail node’s next node will be head and head node’s previous node will be tail.

What Great .NET Developers Ought To Know (More .NET Interview Questions and Answers) – Part1

In this series of posts, I will try to answer the questions posted by Scott Hanselman here. This part we will be seeing the first set of questions he has given under Everyone who writes code heading. Q) Describe the difference between a Thread and a Process? A Thread is a small unit of code in execution. A process is an instance of program which will have multiple threads running. A process can host multiple threads.

ADO.NET best practices – Reading data from data reader

I have seen many people using DataReader incorrectly. In this post, I will try to explain some good practices that can be followed when reading from a data reader. Consider the following problematic code, SqlDataReader reader = /* ... */; while (reader.Read()) { string userName = reader["user_name"].ToString(); int age = int.Parse( reader["age"].ToString() ); /* ... */ } reader.Close(); How many problems can you figure out from the above code? There are many problems with this code,