Category Archives: Code Snippets

Short and usefull code snippets and tutorials used in day-to-day programing

Design Patterns – Part Three: Singleton

Today I will describe the Singleton pattern, one of the simplest, yet generating active discussions all over the net. Some people consider it to be an antipattern. We have many different flavours of this pattern, singleton can be thread safe, lazy loaded, eagerly loaded, implemented as a static class or enum. Simple thread safe implementation: […]

Read More →

Design Patterns Series – Part Two: Template Method

A typical template method pattern consists of the abstract base class which defines one or more template methods (usually set as final) and some abstract methods which the subclass has to implement. Template method defines common algorithm where some of the steps are implemented by subclasses. A Template method pattern provides a skeleton for performing […]

Read More →

Design Patterns Series – Part One: Strategy Pattern

The Strategy Pattern is a first pattern described in a series of post I’m planning to make regarding this topic. The Strategy pattern allows us to select a specific algorithm at runtime and its one of the simples design patterns to grasp. The scenario described on the diagram below shows a simple usage of the […]

Read More →

Google App Engine – Querying related table using Key object

This is just a short note on how to query related entities in JDO. As I have found out, we cannot use the entity key as its shown in the Data Store Viewer on the GAE admin console eg. zzR0ZXN0cgkLEgNGb28XGQw and compare that using someRelatedEntityKey == zR0ZXN0cgkLEgNGb28XGQw, instead we just provide the whole Key object […]

Read More →

Android Series: GET, POST and Multipart POST requests

Today I will describe shortly how to execute http GET and POST request on Android platform. The code is very simple and straightforward, for post request with attachement, you would have to add apache-mime4j-0.6.jar and httpmime-4.0.1.jar to your build path. HTTP GET try {         HttpClient client = new DefaultHttpClient();     […]

Read More →

Android Series: Using GPS data

In this tutorial i will show you how to quickly get the gps data using your android device version 1.6+. All you have to do is to implement one interface and acquire LocationMangager from the adnroid system service. public class LocationExampleAct extends Activity implements LocationListener{     private double latitude;     private double longitude; […]

Read More →

Android Series: Parsing JSON data with GSON

Today I will describe how to parse json data using Gson open source library and how to convert it at the same time to java objects. This is a typical cookbook example and should be very easy to follow. 1. Create an Android application with one activity, name it as you wish, if you are […]

Read More →

Getting started with Apache Click and Eclipse Galileo

Last couple of days I read here and there about Apache Click, which is now in version 2.1.0. It looks preety cool and easy to learn, so I decided to give it a try and see for myself. I understand that its cool to learn things using vi and shell only, but when you tried […]

Read More →

Jasperberry – the most dynamic reports ever.

Today I will describe in short my latest and simplest quick and dirty trick, generating jasper report dynamically. Jasperberry is a component written very quickly to help me generate pdf report in a situation where I don’t know the number of columns I will have, I don’t know their widths, the data they contain etc, […]

Read More →

Deploy your Java Application with IzPack Installer

izpack installer foldersDeploy your Java Application with IzPack Installer

Read More →