Reinventing the wheels

As per Wiki’s deleted (Yeah! I found below content from Google’s cache) article on this
“Reinventing the wheel is a phrase that means to duplicate a basic method that has already previously been created or optimized by others..”
Lets get back a couple of steps, when development of software begins, it usually starts with a prototype, and when things start getting complex the development team starts taking out common code and create frameworks around it. These frameworks are then used / improved by the developers.
Read More!

Capturing Screen in Java, Your Own printscreen

I happened to visit a cyber cafe for some reasons, and I had to take the screenshot of the screen and Alas, for some (security :P) reasons, print screen was not working. Grrrr..
Luckily, the guy had JDK installed on his machine and I had some good 10 – 15 minutes to pull this up. So I decided to quickly use Java to capture the screen and thought to share the Utility with you. Offcourse! I have now added Swing help everyone out here.
You can skip the entire post and can play around with the code / utility with section downloads below –
Downloads –


No I want to code!

Understanding Byte Code in Java

[Q] So, what is Java Bytecode ?
[A] Bytecode is the heart of Java portability. Each Java program you write is first converted to a .class file (bytecode), which is then interpreted by Java interpreter.
Few days before I came to an interesting post, which provided a sample code in Java byte code format. Interestingly decoding the code to Java was no big deal as plenty of tools are available like JAD.
But it sparked something more than just the sample code, why is byte code important and why must a Java guy know that ?
Know Why!

Creating and reading Annotations & Reflection in Java

Annotations are very helpful tool while programming in Java. It is a alternative to the traditional XML based configurations. Spring has picked it up early and I must admit quite beautifully.
In case you are working on something and want to use annotations for your code, here is a small guide; it will definatly make your code look clean and also will kick off the trouble of reading XMLs.
For simplicity, lets create a mock of reading column name and its value, similar to JPA.
 Get the Code

Extending Our NodeJS static + Dynamic Server

Here, we would be extending / simplifying our server that we had made in our last post here.
Objectives –

  • We had a static URL handler which was invoked when URL pattern had /static/. It made the design very specific and not generic.
  • Need to make sure that in case there is no URL pattern handler for a given URL, a file for same name must be looked. If there is no such file, just raise 404 error.

 Get the server

Fully Functional NodeJS static + Dynamic Server

Off late I have seen many people struggling with creating a static Node server, also there have been questions like “How to have static & Dynamic files served by Node”. So here I have a fully functional server that can serve both static as well as dynamic files. Off course there is no need as there are many frameworks that can take care of these things. But always good to do things on your own to learn a new language or as we say Reinventing the wheels.
Below is the server that decides what content to serve based on URL. I have used /static/ to mark static content from URL pattern. That is any URL having this pattern would be considered static and would be served from file system.
Read Complete entry

Getting Started with MongoDB and NodeJS

Before we kick start Node application lets start by creating a MongoDB database and credentials. Though creating database, could have been achieved by using Node, but that would not provide us with user & password. And I believe no one would want their database to be accessible to everyone. 😀
I hope you have got MongoDB installed on your machine, just start up the server and open command prompt.

>mongo
MongoDB shell version: 2.0.6
connecting to: test
>use supaldubey
switched to db supaldubey
>db.addUser('supal', 'key')

Node Code Follows!

Your First NodeJs Application

If you are looking for a “Hello World!” example, I am sorry, you have landed to a wrong page, for hello World, your best bet is the Nodejs site.
Lets just have a brief discussion on what Node (Developers kinda like this name than Nodejs) really is. Node is a platform based on Google’s high performance (& open source) V8 Java script engine, if you are a “Geek” you must have read about it as Chrome uses it as well. Node being build on the Javascript engine, provides a JS like environment for Server side development. Yes, you read this right. Node is Server side Javascript framework.
Get the first Node App!

Creating a custom View Resolver in Spring MVC

Spring being one of the most customizable framework, provides an ability to plug in a custom view resolver.
Assume if the web application uses a particular JSP for festive time, having links or logic for some offers while other is vanila JSP page rendering response. I will demonstrate you how to achieve smooth transition in JSPs without messing up your controller return values and thus code release.
I will be using the code base from my previous example here.
Get the code!