Samstag, 26. Dezember 2009

Apache CouchDB: External Process using Java and serving file

Apache CouchDB supports invoking external processes - here is a very simple example in Java, which returns an image (or another arbitrary binary file):


import java.io.FilterOutputStream;
import java.io.IOException;

import sun.misc.BASE64Encoder;

public class ExternalProcessTest {
public static void main(String[] args) throws IOException {
System.out.print("{\"code\":200,\"base64\":\"");

new BASE64Encoder().encodeBuffer(
ExternalProcessTest.class.getResourceAsStream("logo.png"),
new FilterOutputStream(System.out) {
@Override
public void write(int b) throws IOException {
if (b != '\n' && b != '\r') {
super.write(b);
}
}


});
System.out.print("\",\"headers\":{\"Content-Type\":\"image/png\"}}");
System.out.println();
System.exit(0);
}
}

This can be bundled into a runnable JAR file.
Some hints:
  • You might want to make your output return another status code in case an error ocurred
  • You might want to replace the BASE64Encoder class which is part of sun.misc with your favorite implementation.
  • Most base64 implementations add CRLF every 76 characters, which need to be stripped, because CouchDB expects to get exactly one line returned.
  • The Content-Type header should match the MIME-type of the returned file. There are also automatic ways to recognize the MIME-type of a file.
  • Don't forget the ending newline after your output.
Within your local.ini of CouchDB (to be found within etc\couchdb), you need to register your external application:

[external]
test=java -jar C:\ExternalProcessTest.jar 2>1

[httpd_db_handlers]
_test = {couch_httpd_external, handle_external_req, <<"test">>}

  • Java needs to be within your PATH variable.
  • 2>&1 suppresses error output to be logged to the CouchDB log.
  • http_db_handlers registers the handler on database level, not globally.
Additional hints:
CouchDB pipes some request data to the external process, you can receive this by reading from System.in:

String json = new BufferedReader(new InputStreamReader(System.in)).readLine();

In action:


Sonntag, 13. Dezember 2009

Apple, please add adaptive navigation and context-awareness!

My iPhone keeps on filling itself with apps (I wonder how it does that :-D) - some of them get removed directly after install if I don't like them, others are getting my favorites and again others I know I will use them in the future, probably when I don't have wifi or a good reception available, but I just don't need them now. You know about which type of apps I am talking about: white pages, hotel booker, dictionaries, traffic information, converter tools, etc.
Some of them are really useful, but I only need them at a certain time once, or over a certain period of time (mostly for some days or sometimes weeks) - but they still clutter my iPhone - and even more: new apps are added behind them, whether the newly installed app will become one of my favorites or not.

Now this is nothing new and exceptionally specific to the iPhone, we can also see this with webpages and/or information within webpages, also. I might check on eBay 10 times a day if I want to bid on something. But then again I might not use eBay for weeks if I don't want to bid on anything.

It's some sort of situational correlation.

Now with the iPhone,
  • the situation might be that I am currently travelling in a foreign country - let's take France for example, I would need my french dictionary often and definitely my other dictionaries are more or less useless while I am travelling - so are the apps I have for public transportation schedules in Germany.
  • the situation might be, that I have a certain task to do - search for a suitable name of an yet unborn child for example - I don't know if there is an app for that (there probably is!), but it definitely gets used less frequently once I found a name or the child was born.
  • the situation might be, that I am at home - in which case I probably will use my computer to check my newsreader or do some instant messaging instead of the according apps on my iPhone - but I might be still interested in my games or the birthdays of my contacts.
  • I am probably less interested in booking a hotel when I am in a 50 miles range to my home.
  • I probably won't need my compass when being at home.
  • etc.
For all of these cases, there are some keywords which might lead to an answer: context-aware computing, adaptive navigation and situational applications.

Now why do people use none of these keywords together in one sentence with the iPhone? It seems like a perfect candidate for such technologies:
  1. My iPhone has the ability to know where I am.
  2. My iPhone has the ability to make a good guess about which language I prefer.
  3. My iPhone (probably) has the ability to know whats on my mind when I checked for a baby name in the [put a name here] app, the thousandth time this week.
  4. My iPhone has the ability to know, that I didn't use this nameless application with the hideous icon within the last five weeks.
I want my iPhone to act accordingly.

Now in order to let my iPhone do this, there are some requirements.
  1. Some sort of  matching, using evidence sources to find out where exactly I am (what my current context is) - like MarcoPolo does it for example.
  2. Some sort of awareness how often which application is used and in what context (see 1.).
  3. Some sort of mechanism to adapt the navigation dynamically (e.g. re-sort and/or hide my apps) based on 1. and 2.
Those three requirements would allow for a full-fledged context-aware computing on the iPhone.

Example

By default my iPhone screen looks like this:

Lets make the assumption, that:
  • A is my text messaging app, which I use wherever I am.
  • I am currently at home and I definitely do not need apps I to L because they do something I can do better at my laptop and my laptop is currently also started.
  • I definitely don't need my car navigation, which is B.
  • There is a game R which I bought at the beginning of this week and have played this for some time when being at home.
Then the iPhone screen could look like this:

Samstag, 28. November 2009

Lotus Expeditor: Using custom launch items

When working with Lotus Expeditor and you want to add a custom launcher item to the "new" section in let's say Lotus Symphony for example, there is not much help available out there.



Sure, there is the description of different launchers in the Information center, but it only explains how to use urlLaunchItem, nativeProgramLaunchItem and perspectiveLaunchItem in detail.

So this article is for you out there searching Google for a how-to.

First define the Launcher in your plugin.xml:


(sorry Blogger didn't let me input XML here...)

Now this registers a new item (launchItem) and defines a launch item type (launchItemType) which gets invoked when clicking on it (see type attribute of launchItem and name atttribute of launchItemType).
The launchItemType invokes a class (see class attribute of launchItemType) which needs to be a subclass of com.ibm.rcp.ui.launcher.LauncherContributionItem (attention: com.ibm.rcp.jface.launcher.LauncherContributionItem is deprecated and should not be used).

The referenced class in launchItemType itself should look like this:

package com.xyz;

public class MyLaunchItemTypeClass extends com.ibm.rcp.ui.launcher.LauncherContributionItem {
@Override
public void launch(int arg0) {
super.launch(arg0);
System.out.println("LAUNCHED!");
}
}

also don't forget to put com.ibm.rcp.swtex and com.ibm.rcp.ui on your required bundles list in MANIFEST.MF.

Dienstag, 24. November 2009

Google Reader integration for GMail

Today I spent some minutes on writing a small Google Gadget which can be used to integrate the Google Reader into GMail.

You can add it to your GMail by enabling the "Add any gadget by URL" Labs feature within GMail and then add the gadget with this URL: http://gadgets.feth.com/reader/reader-gmail.xml.

It will display a small tab in your sidebar from which you can access Google Reader. The Reader will open in the area where you normally read your mails and will look like this:

Please feel free to write a comment and/or rate this gadget. If you encounter any problems, feel free to send me a note or use the comments section!

Mittwoch, 18. November 2009

The Enterprisity

I am so frustrated today...I definitely needed to translate an (relatively unknown) urban definition to English which exists in German since 2007 (Thanks to Michael Kukat):

Enterprisity - Measure for the adequacy of a method, a software or a person for his/her/its application in an enterprise, especially in major corporations. Important distinguishing features regarding enterprisity are the artificially boosted complexity, the resistance to counseling (primarily those of persons), the high demand for process orientation simultaneously paired with the preferred total circumnavigation of it, as well as the most miserable performance in comparison to competitive products (or persons) at the most terrible price.

Possible uses:

What the heck... I think the enterprisity got me - I didn't get any work done today!

God I love this company, there is such a low enterprisity, it almost feels like working on an Open source project.

Shoot! Why do I need to work with this rubbish - are they still trying to maximize enterprisity?

If you are a native speaker, please use the comments to help me remove any expression flaws from the definition. Thanks ;-)

Freitag, 30. Oktober 2009

Possible iPhone slide to unlock usability enhancement

Update on 2 Dec 2010: Just found out that Sony Ericssons Xperia x10 actually has an ergonomic slide to unlock area. Yay!

Did you ever try to place a call with your iPhone while carrying your notebook?

Did you ever receive a call on your iPhone when carrying your meal?
It's not so easy to unlock the iPhone or accept that call while being only in possession of one hand, right?!
And also while it is possible to just do that little slide with only the thumb of the very hand also holding the iPhone, it is just not very convenient. Feels more like having played F1 Race on a Game Boy for the last 4 hours than using a phone designed by a company known for its excellence in creating products with an extraordinary usability.
When looking at a sequence of images about unlocking an iPhone with one hand, one can see, that the problem actually seems that the thumb itself needs to be bended too much to stay within the slider area:

The reason for this is that hitting the slider area implies moving the finger in a straight line, which is just not a natural movement for the thumb. A wipe movement in a curvy line is much easier to accomplish and also feels more natural:


So one possibility to improve unlocking with one hand would be realigning the slider area from a straight line (see "traditional" in image below) to a slightly bended line (see "thumb-friendly" in image below):

Realigning the slider area has one major drawback though: the background image gets overlayed by it. While I would still favor that approach and also would be willing to have my background image overlayed with a semi-transparent slider area, but I know that many of you will disagree with that, so the logical continuation of my approach to improve the slider usability is using a slider "knob" which can be dragged freely over they iPhone's display in any direction and with any bending:

As soon as the knob has been dragged far enough from its initial position this will unlock the iPhone (or accept a call certainly). This would maximize the ergonomics of the movement, as people with different hand sizes and/or different likes in thumb movement can choose the one which is the most natural to them.

To carry that thought a bit further, this could even allow for unlocking the iPhone not via entering a pass phrase or some numbers, but only by dragging the knob in a previously defined gesture:

Are these ideas feasible? Any additions? I'd love to hear what you think in the comments!

Mittwoch, 16. September 2009

Free VoIP calls with sipgate on iPhone using XSPhone

Today nothing developerish (sorry to all you frequent readers out there), but something not minor interesting. Yet, only for all of you out there being in possession of an iPhone or iPod touch (2nd generation).

On my search throughout the Apple App Store for neat applications I might miss, I came across a very simple (but nonetheless interesting) free application, which is called XSPhone.
XSPhone is a phone application officially designed for use with the dutch ISP XS4ALL, but implements the standard Session Initiation Protocol (better known as SIP) and is (according to XS4ALL) [...] suitable for use with XS4ALL’s Talk subscription, but also for other VoIP providers that use the SIP protocol [...].

I personally use sipgate, which is popular in Germany, but also is available in the U.S.. So I thought I should give XSPhone a try with sipgate. And, behold, it works! Even incoming calls are possible.
Due to the restrictions for calling apps on the iPhone, everything in this article only works over a WiFi connection, not with a mobile internet connection, though.
So let's get this up and working.
First, install the app (if you didn't already). You can either search for "XSPhone" or click the App Store link provided above.
Then, let's get your VoIP credentials.
For sipgate you can find them in your settings after logging into your sipgate account.
Sorry, screenshots are in german, too lazy to search if I can switch to english ;-)
Within your settings page, you should see a screen with two grey boxes, one of which reads "Account data":

and the other one "Server data":

Now go to your XSPhone settings (you can find them in the iPhone settings menu at the bottom, where the settings of any installed app can be configured) and enter the gathered credentials.
  • Number 1 is your user name (corresponds to your sipgate SIP-ID).
  • Number 2 is your password (corresponds to your SIP password).
  • Number 3 is the VoIP server to register to (this is sipgate.de in my case).
  • Leave the voicemail number empty (I couldn't get it working correctly with sipgate, it might work with other providers, though).
  • Check the experimental option "Allow incoming calls" - at least with sipgate it works. The app needs to be running to accept incoming calls, certainly (Doh! :-).
After you configured the app, you can fire it up. If everything was configured correctly, you should see a screen which looks like this:
In case of sipgate you can either try calling the test number (which is 10000), the echo service (which is 10005) or your mailbox (which is 50000). All of those numbers are free of charge when calling over sipgate.
Unfortunately the mailbox button does not work correctly, but you can add an entry for your sipgate voicemail to your address book and add it to the "Favorites" tab from XSPhone. Calling this favorite works fine (I wonder what difference using the mailbox button makes).
That's it, you are all set for VoIP calling (and being called) over sipgate.
There are some drawbacks, however, I need to tell you about this solution:
  • You can only be called if the app is open.
  • XSPhone only supports one single VoIP registrar at any time.
  • XSPhone does not look as nice as some iPhone applications do (there is some ugly background picture I did not dare to make a screenshot of, when you are calling someone) - although all the other VoIP apps currently in the App Store are also not exactly beautiful either, and at least, this one is free of charge!
  • No SIP-finetuning with proxy, STUN server, etc.
Apart from that: yep, that is a cool freebie!
I'd love to hear about your experience with XSPhone and your ISP (if you got it working, please include a short settings description for all the others out there) in the comments!

Update (2009-09-16): as of now there is an application from sipgate available within the App Store (search for "sipgate") - currently only working with sipgate team edition - in some weeks a version for the other sipgate plans should be available.