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.

Read On →

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 Read On →

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. Read On →

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. Read On →

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. Read On →

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. Read On →

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. Read On →

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. Read On →

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. Read On →