I grew up in Oman and lived there until I finished high-school in 1999. In 1991, when I was ten years old, my father bought me a 386SX for my birthday having noticed my burgeoning interest in computers. For the first few months, I mainly played games. But even that was a non-trivial endeavor in…
Category: Java
Don’t use class literals as type-tokens
Generics were added to the Java language within J2SE 5.0, and there was much rejoicing. It was finally possible to deal with containers in a type-safe manner. Prior to the availability of generics, Java developers had to do things like this: List people = new ArrayList(); people.add(new Person("Donkey Kong")); people.add(new Person("Guybrush Threepwood")); Person pirate =…
Heroku template for Spring 4 app with Oracle Java 8 and Tomcat 7.0.54
I’ve been playing around with Heroku at work for the past week or two. Heroku is pretty awesome if you want to get an app up and running quickly. Heroku does support Java and they have a few Java templates. Their current offering for Java uses Spring 3 and Tomcat 7.0.54 with Java 7. However,…
The image that lied about itself
A few weeks ago, I ran into a puzzling issue at work. Someone was uploading an image which made it past our file-size checks, but caused an OutOfMemoryError and a heap dump when the code attempted to resize it. The information we had from the heap-dump was that it was trying to allocate memory for…
JavaOne
I am at JavaOne! The last time I was here was in ’08, when it was run by Sun. Of course, it’s run by Oracle now. The first day has been pretty good. I attended sessions on Garbage Collection, the Nashorn JavaScript engine, writing DSLs, and about parallelization options offered by JDK 7 and 8…
Implementing pinch-zoom and pan/drag in an Android view on the canvas
I was trying to get pinch-zoom and panning working on an Android view today. Basically I was trying to implement the same behavior you see when you use Google Maps (for example). You can zoom in and pan around until the edge of the image, but no further. Also, if the image is fully zoomed…
Akṣi: Handwritten-digit-recognizing neural-network
I’ve always been interested in Neural Networks (ever since I first found out about them around 10 years ago). However, I never got a chance to learn about them or write one of my own; this is something I’ve wanted to do for some time. I got the opportunity this semester when my professor in…
Setting the content type to text/plain for a JSON response from a Spring controller
I was using a jQuery plugin called a ajaxfileupload to upload a file through AJAX. Technically what the plugin does isn’t AJAX. It creates a hidden form and an iframe, and then submits the form using the iframe as the target. The iframe will then end up with the response from the server. This response…
Fixing Maven 3.0.3’s dependency-resolution performance-regression
TL; DR; version: Maven 3.0.3 has a performance-regression while resolving dependencies. This is because it uses version 1.11 of aether. The problem has been fixed in version 1.12 of aether, but a version of maven with this library is not available. I built maven from source with the 1.12 version of aether, so use maven-3.0.3-with-aether-1.12.zip…
Implementing JSONP in Spring MVC 3.0.x
In Spring 3, it’s very easy to get a view to return JSON. However, there is no built-in mechanism to return JSONP. I was able to find a pretty good tutorial That uses Spring’s DelegatingFilterProxy. I implemented this solution and I got it to work, but I didn’t like the fact that I had to…