Yesterday, I came across an interesting question on StackOverflow. The question is as follows: assuming you have a sorted array, is it possible to increment locations by 1 (one at a time) and still ensure that the array is sorted in O(1)? Assuming you are not allowed to use any other secondary data-structures, the answer…
Category: Programming and Development
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…
Rendering a PDF with text-selection, using pdf.js
I have been working a project for the last few days, that deals with rendering PDF’s in-browser. Initially, I was going to parse the PDF and extract the text content, but then I ran into pdf.js, which is a library developed by Mozilla for rendering PDF’s in-browser via JavaScript. The project I am working on…
A simple trie-implementation
I’ve known about tries for sometime. They’re a pretty neat data-structure for storing and looking-up strings.I decided to try and implement one in Java so that I can learn more about them. I’ll post another article later that goes into some more detail about this implementation, but for now you can check out the source…
The Feast
Inspired by The Codeless Code: The master was meditating when a priest respectfully entered his chamber. The master opened his eyes. The priest bowed respectfully and said, “Master, I would like you to look at the code of a young disciple of mine”. The master nodded and followed the priest to a computer. On the…
Data and Code
Inspired by The Codeless Code: A novice monk had just started learning assembly programming when he was troubled by doubt. He approached his master and asked: “Master, how do I know which is code and which is data?” The master who was meditating, opened his eyes, smiled, and said: “Each is the other, yet neither…
Indenting XML and HTML from vim
vim has an awesome feature, using which you can pipe a range through an external command. This is pretty useful if you’re opening up an un-indented or poorly-indented XML or HTML file. If you want to indent your entire file, simply do the following: :%!tidy -i -xml -q The -i option tells tidy that it…
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…