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 →

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

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

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

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

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