Scriptico

Qantas

I do not really like flights. I do like planes as a genius of engineering, I do like take offs because of the power and speed, but I hate the rest – endless hum, bums, and food it-always-has-the-same-taste. Well, I am assuming if I flew first class, I could enjoy flights more, yet my bank account is weak for such things.
For the last three weeks I did about 30 000 miles and at the begging I expected all the same (see above), yet Qantas added some spicy details in my trip.

The QF128 flight from Hong Kong to Sydney takes about 9 hours (Boeing 747-400). Amazing service, great board attendances, more-or-less comfortable seats, and a lot of Australian wine during the flight. However, one thing was “funny”.  Read the rest of this entry »

HP IDOL OnDemand. Query Text Index Example with UI

With the Query Text Index Swift Example article, I demonstrated how to query text indexes in IDOL OnDemand. A simple RESTful client was created to make a call to API and output the result. For that example, I used Xcode Playgrounds and unfortunately, I did not find a way to make UI written in the playground responsive to user’s actions (text inputs, button clicks, etc.). Eventually, I came to the conclusion that for now such features are simply not supported, and decided to make a simple iOS application to demonstrate how to communicate between UI and the client; this article describes how to do so. Let’s begin! Read the rest of this entry »

HP IDOL OnDemand. Query Text Index Swift Example

HP IDOL OnDemand provides format conversion, image analysis, indexing, and text analysis RESTful APIs to help the developers process unstructured data and build amazing, innovative, flexible, and robust solutions.

The following article demonstrates how to consume one of the available HP IDOL OnDemand APIs and query a text index from an application written with Swift, a new programming language for iOS and OS X. Let’s start from the basics. Read the rest of this entry »

Clean Spring MVC Web Application

As a base for the future blog entries, I have created a simple web application based on the Spring Web MVC framework and checked it in to the git repository. If you just want to take a look at the application (or maybe use it for your specific purposes), please use the github repository; however, if your are interested to create an application on your own, the following steps may be beneficial for you. Read the rest of this entry »

First Experience with Servlet 3.0

Das Ostern is finished and finally, I’ve been assigned to a project. As you know, sometimes it takes a few days to prepare environment, setup all accounts, and so on. Thus, during the last two days my schedule is pretty much relaxed and I can spend some time for self-education – I am reading the Servlet 3.0 specification, writing some simple application in order to try discovered features, and wondering about two things: how really cool servlet 3.0 is and how I could missed it?! If you did not touch it as well, take a look on the following briefly Read the rest of this entry »

Issue with Facebook Key Hashes for the Android Application

During the last three months I have been working as a developer for a consulting android project. It is actually my first commercial experience (I do not count written demo examples at my previous work) and I found it extremely interesting, though a quite confusing at some moments.

The following article describes an observed problem with the facebook key hashes for the android application. To describe the problem and its solution, let’s define a simple use case.
Read the rest of this entry »

How to restart an application in android programmatically

The following code snippet shows how to restart an android application after the specified delay programmatically:

public void restart(int delay) {
	PendingIntent intent = PendingIntent.getActivity(this.getBaseContext(), 0, new Intent(getIntent()), getIntent().getFlags());
	AlarmManager manager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
	manager.set(AlarmManager.RTC, System.currentTimeMillis() + delay, intent);
	System.exit(2);
}

Related API:
PendingIntent
AlarmManager

How to minimize an application in android programmatically

The following code snippet shows how to minimize the current application in android programmatically:

Intent main = new Intent(Intent.ACTION_MAIN);
main.addCategory(Intent.CATEGORY_HOME);
main.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(main);

Related API:
Activity

Oracle Certified Professional, Java SE 6 Programmer. 1Z0-851 Exam

Finally, I did it. About a month I have passed the java certification exam and it was not that hard as I expected. A brief story how it was.

Firstly, let me give a few cents about the exam preparation. The rule is really simple: if you have a few years (or even not a few) of the experience with Java and you believe that you do no need to read any books and you are by now ready to take it – forget about it, you will most likely fail, because of the specific exam pitfalls. Take a week or two and play with the exam preparation materials.
Read the rest of this entry »

Hibernate. How to Count Records

Easy as ABC, you may answer, and you will be absolutely right! It is not rocket science, yet some code looks quite complicated to complete this simplest task.

Today I watched a new episode of the Bones tv show and browsed some open source code. I found the following method:

public int getCount(Class clazz) {
	Integer rowCount  = new Integer(0);
	Criteria criteria = getCurrentSession().createCriteria(SomeEntity.class);

	List results = criteria.list();

        if(results != null && !results.isEmpty()){
        rowCount = results.size();
	} else {
		rowCount = new Integer(0);
	}
	return rowCount;
}

Okay, 11 “readable” lines of code so far. Read the rest of this entry »