Ramblings of a Coder's Mind

Got Tech? Will Hack.

ThoughtWorks Welcome Video

I usually don’t post much about work but this is something I’ve never done before and would like to remember for a long time. I joined ThoughtWorks early August 2014 and by the end of it 8 of us had joined the Pune office in the month. We got together to create a video to introduce ourselves to the ThoughtWorkers in Pune (not that there weren’t mails floated with our pictures, a jazzy 3-4 line intro and tons of talking to people around the office). I’m not sure if anything of the sort has been done in the Pune office but we certainly got a nice response to the video.

Read on →

Project Euler #79: Passcode Derrivation (using Lambdas)

I’ve been solving Project Euler for years and I avoid posting solutions online as far as possible but this problem is old enough that it shouldn’t be a problem. Plus, the problem statement interests me enough to write a functional solution using the new Java 8 Lambdas that I’ve been experimenting over the past few months.

Before I begin, I’d like to acknowledge Alex Michael for providing the base solution with a pretty nice explanation of how to crack the problem. You should read through his post before you continue.

My solution provides a Java port of this solution using Lambdas. Here are the steps to the solution

Read on →

Set Java Home to a specific version on Mac

Installing Oracle’s version of Java on your machine does (for most machines I’ve encountered) add a Java Home system variable. Rarely however it doesn’t work on some machines. Such folks are recommended to add the path themselves.

On a Mac, you can do this by using the following

export JAVA_HOME=$(/usr/libexec/java_home)

This information is littered across the internet and isn’t hard to find at all. However, this specific machine, when upgraded from Java 1.7 to Java 1.8 kept insisting it’s home is Java 1.7. The Java Home script at /usr/libexec on the mac should take care of this

Read on →

Java 8: Generic Method Returns with Lambdas and Strategy Design Pattern implementation

With the introduction of Functional Programming in Java 8 new possibilities have opened up. One use case I recently encountered was that of processing JSONs to return data inside them. Let us, for the sake of argument, say the data in an element could be one of the following:

  • An Integer e.g. 1
  • A String e.g. The quick brown fox jumps over the lazy dog
  • A JsonObject representing a Java Object e.g. {"payload":[{"lastName\":\"AB","firstName":"Karun","email":"test[at]email.com"}
  • A JsonArray containing Integers e.g. [1, 2, 3]
  • A JsonArray containing Strings e.g. ["String 1", "String 2"]
  • A JsonArray containing JsonObjects representing Java Objects e.g. [{"lastName":"AB","firstName":"Karun","email":"test[at]email.com"},{"lastName":"FooBar","firstName":"Kung","email":"kung[at]foobar.com"}]

If you want such a wide variety of data parsed and handled (relatively) safely (i.e. with compile time type safety where possible), here is what you do.

Read on →

Karun AB, that's me!

It’s been almost a year now since I bought the domain http://karun.me and a few months back I decided to put in some of my free time to put something up there. The domain, being named what it is, makes sense to house things about who this mythical Karun is and what he does. Seems he mostly does code for random organizations and at times is allowed to talk a bit about it :P So that’s what the website tells you! He also seems to take some photographs so the website helps show that off as well.

So, anyone who’s

Read on →

WildFly: Server Side Variables/JNDI Custom Resources

As you probably know, Oracle stopped development of Glassfish’s commercial version and in doing so, prompted others to move. News of Glassfish being dead is greatly exaggerated according to some but myself being one who was already not happy with Glassfish’s Open Source version, steps were taken to move to WildFly. So far, the move has been well received in the team except for web based GUI administration panel which isn’t complete. Reliability of the admin panel is higher than Glassfish’s counterpart though and what WildFly’s web admin panel lacks, it’s CLI and Swing based GUI admin panel make up for allowing script writers (such as myself) to come up with automated ways to get things done.

A while back we discussed how you could use JNDI custom resources on Glassfish to set environment variables. Migration for our team meant information setup as environment variables need to be setup again.

Read on →

Atlassian Bamboo: Downloading Code from Atlassian Stash

The Atlassian suite of tools are a good way to have your organization’s workflow administered. If you’re using Atlassian Stash to manage your source code and are attempting to get Atlassian Bamboo to download code off Stash’s copy of git, the answer isn’t quite straight forward.

Having experience with Atlassian’s tools for over a year, one gets used to excellent integration wrapped up with beautiful UI but when it comes to setting up flawless CI with Bamboo, you’re let down (either that or my integration is non-standard; don’t see how).

Read on →

Eclipse Plugin Development: Project Icon Overlay

If you’re trying to create a Custom Project in Eclipse, you’ll eventually come to read a beautiful blog post over at Hidden Clause that documents quite well how to overlay your icon over Eclipse’s default folder icon to get the icon of your choice.

If you’re default project is an extension of an already existing project (I, for example, wanted a custom Java Project type so I extended Eclipse’s New Java project wizard to get desired effect), the default nature added is that of Java meaning Eclipse adds it’s icon and not the icon you’ve set up. The issue

Read on →

Eclipse Plugin Development: Attaching Sources

As a developer, I like to look at the source code for the libraries I use in order to understand if what I am doing is the best way to implement it or not. Though Eclipse, by default, comes with features to develop plugins, it doesn’t come with the source code for this. Getting the source is a simple, 3 step process!

  • Help > Install new Software

  • Work with ‘The Eclipse Project Updates’ (not the main site!)

  • Install the following items

    • Eclipse RCP Plug-in Developer Resources

    • Eclipse PDE Plug-in Developer

      Read on →