Ankit Gupta

Replacing dual boot with Bash on Windows

For most of my career, I have found a computer with dual boot setup — Windows and Ubuntu — to be an essential component. I use Ubuntu for all the software development and Windows for editing word documents, working with Adobe products, and playing games (something which is still largely absent from Linux distributions). Until recently, I have found that writing code on Ubuntu to be very efficient. Compared to when I was using Windows along, it saves me a lot of time wasted in trying to get some compiler/framework to work and dealing with incompatibility issues on Windows. A simple apt-get install on my Ubuntu machine goes a long. The only drawback of this setup is that I have to switch between the two operating systems. I cannot switch to a short burst of gaming and get back to work. But, that never became a huge issue.

More …

Is Chromebook for you? — the goods and bads of a Chromebook

My Lenovo laptop broke a few months back. I sent it for repairs and needed something cheap and lightweight in the meantime. I always wanted to use a Chromebook for fun but never considered it suitable for my needs as I develop primarily in Java. However, this time I was working on some projects where I was doing front-end web development and visualizations and a Chromebook would would have worked for me. I could still ssh into my Linux box to do some Java development (although I won’t recommend it). I finally bought a  Acer Chromebook 13 (CB5-311) and I have been using it regularly for over a month now. I have some good and bad things to say about Chromebooks and a little something about the whole idea of “moving to cloud”.

More …

Heat Map Chart of Semantic Role Labels

While doing text analytics on a large document collection, the analyst is often looking for relationships between entities like person, organization, location etc. The existing approaches to finding related entities automatically are quite primitive. They are generally some variant of finding relationship by co-citation of entities and bibliographic coupling of documents. According to this scheme, two entities are considered “related” if they are mentioned in the same document. Conversely, two documents are considered related, if they have common entities mentioned in them. A major problem with this scheme of “relatedness” is that the nature of relationship (semantics) between two entities is unknown until the documents mentioning the entities together are not read by the analyst.

More …

How to use Swing widgets in an Eclipse RCP application?

Eclipse RCP is a great platform for developing nice GUI applications with Java. It provides a wonderful framework to build application with its very useful publish-subscribe event model and annotation based dependency injection. It feels almost like magic when you switch from developing hard-coded Swing applications to Eclipse.

More …

Don't teach them calculus before they can add !!

Lately, there has been quite a discussion online about changing ways to teach computer programming. Programming is being realized as a very useful tool for practitioners in almost every domain. Yet, the way it is being taught continues become more and more convoluted. As a result, more and more students are frightened of the word “ programming”. We have finally managed to make a beast out of something that is amazingly simple in reality. We have also managed to kill the fun and joy that programming has to offer.

More …

First Date with Blender

Blender is a great free and open-source tool for creating 3D computer graphics. In my knowledge it is the only open-source tool that gives a real competition to its commercial counterparts. I have come across it several times and always wanted to learn it. But, I kept procrastinating. Finally, I got some free time last week and got hands on a very nice video tutorial on YouTube. The tutorial is easy to follow and I was able to learn the Blender interface and was able to replicate the tutorials to produce some really nice graphics that I am really proud of. Here are couple of images that I have created so far.    More …

What can you do with Java annotations? – Part 1

Java 5.0 introduced annotations among many things. Annotations are a way of adding metadata to Java elements such as classes, methods, variables, parameters and packages. An annotation in its simplest form looks something like this:

More …

What does brushing and linking mean in information visualization?

Visualization systems generally consist of several independent visualizations, each allowing exploration of a different aspect of data. Over years, researchers have developed several interaction techniques to allow users to explore data. Two of these several techniques are Brushing and Linking.

More …

How to run a loom project from sublime?

Loom is a game engine that provides live update functionality which makes testing code very easy. It is slowly gaining popularity at least among the newbie game developers and students (ones like me) as it is free and provides normal developers to take a shot a game development. without too much investment. As it does not come with any IDE, I tend to use Sublime Text for development with loom. If you are doing the same, you might need some build system to build+run loom from within Sublime. Below I am sharing the steps that I took to achieve the same. Although I am using Windows for my example, you can use any OS to achieve the same with appropriate changes. Here it is: Go to Tool > Build System > New Build System... Then add the following code to the build script that you get {<br /> "cmd": ["loom.bat", "run"],<br /> "selector": "source.ls",<br /> "path": "C:\\Program Files (x86)\\Loom\\bin"<br /> }<br /> and save the file in the Packages directory. Update: I recently found this project that is allows much more than just running a project. More …

Dealing with missing headers and files on Debian when compiling software and libraries.

If you are using any Debian-based OS like Ubuntu for some time, it is possible that you might have tried to compile some library or software and encountered the same old error like this fatal error: xyz.h: No such file or directory At this time, you are really pissed off as you do not know where to find this header. Now, first you will try to google it and if you are not lucky (which happens with me a lot), you will not find any useful thing. However, I recently discovered that at this point too, there is some hope left. If the header belongs to some Debian package, you can use apt-file tool to find which package it belongs to. To do this, first install apt-file. sudo aptitude install apt-file Then update it using sudo apt-file update This will load the relevant information to find what you are looking for. Then do apt-file search xyz.h And if it is indeed a header file from a debian package, you by now have gotten the relevant information to install the appropriate package. More …

What is the fastest way to find if a number is prime?

Quoting wikipedia, A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. So, at times you might find a need to check if a number is prime. And if the numbers to be checked for primality, you might need the fastest implementation. In this post, I am sharing the implementation as suggested by the algorithm here. boolean isPrime(long number) { if (number == 2) { return true; // 2 is a prime } // if the number is even if (number % 2 == 0 || number < 1) { return false; // not a prime. } // a number would be prime if it is not divisible by a number less than or equal to its square root. double root = Math.sqrt(number); //we start the loop from 3 (2 is already checked above) //Additionally, we will increment i by 2 as checking for even divisor is not required at this point. for (double i = 3; i <= root; i = i + 2) { if (number % i == 0) { return false; } } return true; } More …

Processing: My first impressions

Long I have not known about an interesting environment for working on graphics and animation. It is called Processing. I have long been using Java for all my desktop application needs (with occasional also some animation/custom component coding in Swing). So, I know the pains of developing even a simple visualization, animation or even a worthy UI using Java/Swing.

More …

Animating the console!

There are times when I love to use command-line/terminal (whatever you want to call it). And when I do I like to do something fun with it, and not just putting text to read. This post contains two examples of some fun code that you might wanna use to make something nice of your command-line application. The first example is a rolling piece of text on console (something similar to what you might get from the HTML marquee. /** * MarqueeOnConsole.java * Following piece of code available to use without any fee for any closed/open-source project. * Creates a HTML-marquee-like text on console. * * @author Ankit Gupta * @version 1.0 */ public class MarqueeOnConsole{ /** Width of the marquee in terms of character. **/ public static final int CONSOLE_LENGTH=40; /** Creates a rolling marquee on console. **/ public static void main(String []agrs) throws InterruptedException{ String text = "This text is rolling!"; int prefixLength=-1; while(true){ String prefix = "\r"; prefixLength++; if(prefixLength>CONSOLE_LENGTH){ prefixLength=0; } for(int i=0; i < prefixLength;i++){ prefix += " "; } int endIndex = CONSOLE_LENGTH-prefixLength; if(endIndex > text.length()){ endIndex = text.length(); } String printableText = text.substring(0,endIndex); System.out.print(prefix + printableText); Thread.sleep(100); } } } This second example is the one that simulates the process completion that you see on console with increasing percent. The key in both the example here is the use of “\r” (carriage return character). What it does is that it moves the cursor to the front of the current-line without moving it down (like “\n”). Although, this is not something awesome but still something that might help you make your command-line tool or application look pretty. If you have done some nice effect in your text-based console app, I would like to have a look at it. Send me an email or leave a reply here. More …

Competition, Collaboration and Software.

If you happen to be a guy who has spent some time in online forums for software developers, you might be aware of the flame wars that go on between different software such as vim and emacs or netbeans and eclipse, or between different operating systems. I happen to be the guy who just hates these kind of discussions. The problem with these flame wars is that they start as simple comparisons or discussions and evolve into pure blasphemy.

More …
NEWS
  • 19 March 2018
    I got a full-paper accepted at Pervasive Health 2018
  • 15 March 2018
    Qualified for SFU 2018 3MT finals