Aug 30

My favorite Android apps

As a follow-up to my previous introduction to Android I will highlight my favorite or most-used apps in this post. Those are just apps that don't come with Android itself, such as Google Mail or Maps, just talking about the ones I manually got from the Android market.

Advanced Task Killer

As some apps don’t stop running when you are using the back or home button they keep on running in the background. The Advanced Taks Killer (I use the free version) enables you to kill (as in stop) those processes.
Advanced Task Killer on Android market

Evernote

This app is priceless for taking notes and syncing it with multiple devices (PCs, Macs, Laptop, iPad, iPhone, Android Phone, etc.). The link to the market: Evernote on Android market

Seesmic

My favorite Twitter app for Android devices. I have tried several other ones, but like this the most. Tweetdeck is on my list of Twitter-apps to try out in the near future. If you are using Twitter at all, make sure you give it a try.
Seesmic on the Android market

Opera Mini

This is my browser of choice for my mobile phone and serves me really well so far. I gotta admit that I did not experience big issues with the built-in browser but I kinda got stuck with Opera as my go-to app, wenn it comes to browsing the web.
Opera Mobile Download site

Pkt Auctions

This is a really really good ebay application for Android devices. I have already used it several times when buying/selling stuff on ebay. If you are an ebayer, you should definately check it out. I’ve found it way better than using the ebay mobile site.
Pkt Auctions on Android Market

Endomondo

Endomondo enables you to track your running / cycling / walking / skating / whatevermoving using your phone’s GPS module. Works really well and gives you a detailed overview on where you were and even displays the song you were listening to at a particular spot if you are using your phone as a music player while doing sports. The web interface (you can upload all your workouts) is pretty nice to and the built-in Google Maps (both for web and mobile) display your route. I used it to figure out how far it was from my place to work (6+ miles). Check Endomondo’s download page if the app is available for your phone, too (if you do not have an Android device).
Endomondo on Android Market

What are your favorite apps?

Let me know what your favorite apps are – I am continuously looking for new ones!

Aug 25

Django Dash - Lessons learned

The Django Dash is a chance for Django enthusiasts to flex their coding skills a little and put a fine point on “perfectionists with deadlines” by giving you a REAL deadline. 48 hours from start to stop to produce the best app you can and have a little fun in the process. I took part in this year's Dash and am posting this to give an insight into my Dash weekend.

So a project using the Django framework that has to be completed in 48 hours. I was and still am new to Django, still wanted to take part to get deeper into the development of we applications using this framework. Django is a web framework written in python and is comparable to Ruby on Rails.

The application idea

Coming up with an idea of what to do for the Dash weekend was the smallest problem for me, as I have a collection of a few ideas flying around in my head. My goal was to create a shopping list application. The difference to just a shopping list was that users would be able to create 'their’ supermarket first, they would enter the order of categories as they are lined up in the supermarket of choice. Then when entering the items a user wants to buy the shopping list will be displayed in the correct order. So the items on the shopping list are in the same order as you can find the items in the supermarket. I thought this idea was good and sounded easy enough to complete in 48 hours (actually 48 hours minus some sleep).

The tools I have used

I have used Django before, but not for a project I started from scratch. This blog for example is developed using Django (see Django Mingus for more information), but I am just a user of the blog engine and have not done any development on it.
Django was not the only tool I was using for the first time. I needed to find a text editor to use for development. The ones I chose from included VIM (MacVim) and TextMate. I opted for TextMate as it is a pretty popular editor on Mac OS X and I have not used it. It was fun to use (I used a 30 days test version of it) and it worked pretty well. I liked the fact that I had the project overview and the file to edit in one program. I think TextMate is more than an editor, one could say it is an IDE of some sort.
Another tool I was using – inside of Django – was South for intelligent schema and data migrations. It was easy to install (using pip) and use – I’ll definately use it more often now that I came to use it for the first time.
For the frontend I did not want to write a lot of CSS and so went for Yet Another Multicolumn Layout for the layouting.

The good things

There were quite a few things that worked pretty well from the start. For instance I had no problem implementing the models and writing tests for them, that was pretty easy, see models.py on GitHub.
Another great Django feature is the Admin interface which enabled me to see how the models turned out pretty quickly.

What went wrong?

The first couple of hours of my Dash worked pretty well until I tried implementing the urls.py, views.py and the corresponding templates. There is such a thing called the RequestContext that you use to wrap to request and hand over to the template for access to several variables that the RequestContext provides. Now that I know it – it makes sense and all that, but it took me a while to figure out. It is especially important if you want the use authentication in your template.
Some more problems occured when I was trying to test the templates. As said in the tools section I used a CSS framework for the layouting of the templates. Now when I tried calling the templates from the browser using “python manage.py runserver” the static media files (images, CSS) were not displayed. What was the cause for that problem? Django does in its default settings not serve static files. In production one uses a web server to serve the static files – in development (by default) they are just not being served. To solve this, all you need to do is at:

 if settings.DEBUG:
    urlpatterns += patterns('',
        (r'^media/(?P<path>.*)$', 'django.views.static.serve', {
            'document_root': settings.MEDIA_ROOT,
            'show_indexes': True
    }),
)</path>

to your urls.py. After that the media files are served by Django.

Then for the Dash I had the problem of not being too good in web design and design in general. This is pretty bad when you work on a site from top-to-bottom and do all of the work alone. So, what did I do? I tried to come up with a design:

I definately need to work on this one! ;-) Or the design in general.

What should I have done differently

  1. For one I should not have underestimated how much it takes to finish an app from scratch in 48 hours. If you check out the other participants you can see what is possible in the time frame – just not for me. So lots of respect for everyone who finished their project.
  2. As I am a beginner in Django, Frontend-Design and 'from-scratch-development’ I should have tried harder to find a partner or two to work with – some more experienced ones, enabling me to even learn more from their code / skills.
  3. Be better prepaired, as in know more about Django!

Do I regret taking part and do I think the 48 hours were a waste of time?

No, and you should take part next time, too. You learn a lot, trust me!

Further readings

Please let me know how you handle your Django project in the coments or via Email or via twitter.

Aug 17

The way I use VirtualBox

Virtualization is everywhere. VirtualBox (virtualbox.org) is not new, I have used it for quite a while now but haven't really digged deeper into it. Today a colleague at work told me more about it and I got to love its command line tool: VBoxManage - which you can use to basically do everything that the GUI can do, too, plus more. I'll introduce one nice little feature I came to love today in this very blog post.

The use case

So what do I actually need VirtualBox for? We (at work) have a product that needs Client-installation (which will install a Windows Service and more). There are several different versions of this product that need to be testet. To not mess with my work laptop's operating system I - and most of my team - use virtual machines (vm) for testing. So among other things we use virtual machines to test the client code. We use vms not only for the client code as you can run different operating systems using VirtualBox (see Guest OSes for a complete list), so we test server installations, too.

The usage

Now what is so special about VirtualBox and VBoxManage and what did my colleague tell me? It is the fact, that you can declare your virtual disks (the hard drive of your virtual machine) as immutable. This means that you can not save changes to the virtual disk. So on a restart of the vm it is as it was when you declared it as immutable. This is espacially useful for testing different versions of client code - you do not have to uninstall and reinstall the software, you get a fresh system on every reboot. Using VBoxManage you can later declare the vm immutable, so if you want software installed on the system you can do that and after the install change the disk type to immutable. In case you want to save something you can take a snapshot and start the vm from that snapshot on the next boot.

The command line

In my case I already had a virtual disk that I wanted to use. If you do not have one, you can create one using the GUI or by using VBoxManage in the command line:
VBoxManage createvm
There are more options required but this command will list the needed ones for you.
As I already had a disk I wanted to use I decided to make a copy of it and use the copy to try out the immutable disk type. To do so, all you need to do is run:
VBoxManage clonehd <uuid of the disk to clone> <destination name> --format VDI
</destination></uuid>

This will clone the disk to the specified destination name. There is a
--type
option, too - which did not work for me. If you need to find the of the disk you want to clone you can use
VBoxManage list hdds

for a list of all your disks. As the --type parameter on the clonehd command did not work for me I added the disk to my VirtualBox setup and then used:
VBoxManage modifyhd <uuidname of the disk> --type immutable</uuidname>

This changes the type of the disk to immutable and enables me (and my team) to test different sets a bit quicker.

The conclusion

VirtualBox is a nice and powerful tool - and it is free. I am pretty sure there are more functions I do not know about, so please feel free to share hints, insights or your favorite option of VirtualBox in the comments. VirtualBox runs on different OS, too. I have used it on Mac OS X and Win XP so far without any problems.

The find out more section

VirtualBox.org
VirtualBox wiki page
Virtualization wiki page
Virtualization by VMware

Jun 30

Android - an introduction

Early this year I broke my old phone. It was an HTC S620 with Windows Mobile on it. As I needed a new phone I looked and asked around what people were buying at that time. A friend of mine already owned a Motorola Milestone (Droid is the international name) and I liked it - a lot. The reason for my liking though was not (only) the fact that the hardware is pretty nice but the operating system it runs: Android. This post is an introduction to what Android is and what it does.

What's the background?

Every consumer electronic device needs an operating system that plays the role of a host for the applications one can run on the phone. For mobile phones there are several operating systems from different vendors:
  • Symbian - a now open source platform for mobile devices
  • Apple iOS4 - the operating system that powers the iPhone
  • Maemo - which is now being transferred to Meego (a cooperation between Nokia and Intel)
  • Android - developed by the Open Handset Alliance
There are more solutions than that, but those are the more important ones - at least for private use cases (BlackBerry is a popular one for business solutions). All of the above named solutions are hardware independent - it is 'just' the basis for the software that is going to run on your mobile device.

What is the operating system for?

So one might ask - what do I need an operating system for and what are differences. The operating system enables one to make use of a computer (mobile devices are computers, too). It handles the use of memory, input, output and takes care of the applications running on the phone. So if you start typing on the keyboard of your mobile device and see the text on the screen it is, because the operating system handles the input and hands the input over to the applications (in this example a text application) for further usage. Another example is playing music files. The music application lets you choose the song, the actual output using the speaker(s) of your phone is handled by the operating system. One could say the operating system does the transformation from in- or ouput using hardware to and from software.

What's special about Android?

With the rise of the Apple iPhone and the usage of touch enabled devices there is more people expect from a mobile phone than it used to be. Being able to call or text someone is not enough anymore. People expect to be twittering and facebooking everywhere they go and so they need a platform that enables them to do so. But that is not all. Functionality is worthless if it doesn't look good. You might have the best software but people won't use it if they don't feel comfortable with it. Due to the iPhone and thanks to Apple's advance on the design of User Interfaces / User Interaction people expect all the functionality being really easy-to-use with no need to read 100+ pages of documentation. Android offers all that. An easy way to use your phone - Android is optimized for touch devices and comes with support for voice controling your phone. It is released as an open source platform and available for free for everyone.
There also is the Android Market which enables the users to easily install new software on their devices. Though it is possible to install software using the Market, you can also do so by downloading an Android application, they come in an .apk format which the phone automagically installs to your device after the download is complete. That is a big difference compared to Apple's approach to distribute applications, the only way to install new software on your phone is to get it using the iTunes Store (no judgement on Apple's policy here). You might have come across a so-called QR Code for Android applications. Using the Barcode Scanner application one can scan the QR Code and start the download of the application - all the required information are supplied by the QR Code.

Who develops Android?

Android is developed by the Open Handset Alliance which was initiated by Google and now has a decent number of members. Applications for Android can developed by every developer - there are no fees for application developers to get started and the SDK can be downloaded for free.

Where to find out more?

If you liked this post or have some feedback / comments please feel free to post them below, send me an email or contact me on twitter.

May 17

request.getInputStream(): Tomcat vs. Weblogic

At work I had a weird problem the other day. The product I am working on is a web application - deployed as a .war archive. We usually use a Tomcat (5.5 or 6.0) servlet container and everything works fine: We have POST requests and append byte data to it. We keep a request open and put as many bytes in it as we want (of course this depends on the use case). Now for a client we had to deploy the application on an Oracle Weblogic Server (version 10.3) and found an interesting problem. I will only be talking about the server side code and can't publish the whole application, sorry about that.

  1. How it works using Tomcat

    So on the server side we use the
    ServletInputStream
    
    of a
    HttpServletRequest
    
    of a standard servlet. On that InputStream we receive data using
    request.getParameter("param1");
    
    and keep calling the
    is.read(target, transferred , size - transferred);
    
    method to read the appended data from InputStream. Once that data was read into a
    byte[]
    
    we write this array to an
    OutputStream
    
    .

  2. What happens using Weblogic

    Everything is done using the standard
    javax.servlet.*
    
    classes, no Tomcat specific classes so we thought this should work on Weblogic, too. But we were wrong. After I spent a (long) while debugging the problem I found that on Weblogic, once you have accessed some methods (not quite sure which ones)
    request
    
    object you can no longer read from the
    InputStream
    
    . It seems to me that Weblogic marks the request as totally processed after reading a request, parameter for example:
    request.getParameter("param1");
    
    (this one is for sure causing the not readability of the
    InputStream
    
    ). So once we read the parameter that we needed for further processing we weren't able to read the data appended to the POST request using
    is.read(target, transferred , size - transferred);
    
    anymore.

  3. How we got it to work using Weblogic

    To solve this problem we now don't put the
    "param1"
    
    value as a parameter, we now put it in the request header. Accessing the header value
    request.getHeader("param1");
    
    leaves the
    InputStream
    
    the way we expected it so we are able to read the appended data.

  4. Question

    Maybe someone can answer the question, why are Weblogic and Tomcat handling this differently?

But hey, we got it working. Not even Weblogic was able to stop us. If anything in this post is not clear and you would like to help clarify this but need more information please feel free to contact me or post a comment here.

Update:

Thanks to @royvanrijn I got an explanation for the behaviour described above:

The description for the

ServletRequest.getParameter(String)
method in the Servlet Specification 2.5 contains the following paragraph:

...If the parameter data was sent in the request body, such as occurs with an
HTTP POST request, then reading the body directly via getInputStream()
or getReader() can interfere with the execution of this method...

Knowing this, it makes perfectly sense that the two servlet containers act differently on the same method. What does this mean for us? We'll probably use a header to get the required parameter and not read it from the request body.

Mar 07

Accessing the web using Lua

As a follow-up to a previous post: "Getting started with Lua" I will go into a bit of how to use Lua to access web pages and retreive information over the web. In particular this post wil be about using Lua, Lua socket (for web access) and LuaRocks (for managing Lua modules) to access the Twitter api.

So there are a couple of tools I used to access the web from Lua that I wanna go through first.

  1. LuaRocks
  2. LuaRocks is defined as a tool that allows you to install Lua modules as self-contained packages called "rocks", which also contain version dependency information (see: LuaRocks.org). After installation it's as easy as
    luarocks install [name of luarock]
    
    . There are more functions that will be listed after just typing
    luarocks
    
    on the command line.

  3. LuaSocket
  4. According to the website LuaSocket.luaforge.net "LuaSocket is a Lua extension library that is composed by two parts: a C core that provides support for the TCP and UDP transport layers, and a set of Lua modules that add support for functionality commonly needed by applications that deal with the Internet." Sound perfect for the use case of accessing the web from a Lua script.

  5. Twitter API
  6. Twitter is a famous tool to exchange 140 characters long messages. I offers a nice API that will be useful for testing the web access. In particular the paragrph about using A command line is all you need to use the Twitter API is of interest.

Use LuaRocks to install LuaSocket

LuaRocks makes this step really easy. All you need to do is type

luarocks install luasocket

on the command line to install the LuaSocket module to your system. To test if everything worked, use the lua shell and type

-- Use the luarocks module to load from the 'rocks' module

require("luarocks.require")

-- Load the specific rock: 'socket'

require("socket")

If everything is correct this should run without an error.

Use LuaSocket to access the Twitter API

Now that LuaSocket is installed properly we can use it to access the web. For that we first have to load the required modules:

-- use luarocks to load the modules

require("luarocks.require")

-- load the http module

local io = require("io")

local http = require("socket.http")

local ltn12 = require("ltn12")

This loads the required modules and binds the module to the
http
namespace which makes it easier to use later.

As for every access to a web page you need an URL, we need to construct one. The URL is a simple string that will be handed over to the http module. We just have to get the user login information in order to access the timeline of the user's friends:

print("Enter username: ")

username = io.read()

print("Enter password: ")

password = io.read()

authentication = username .. ":" .. password

myurl = "http://" .. authentication ..  "@api.twitter.com/1/statuses/friends_timeline.xml"

All there is left to do now is to hand over the URL to the http module to perform the request:

http.request{ 

    url = myurl, 

    sink = ltn12.sink.file(io.stdout)

}

The sink parameter will write the result of the request to a lnt12 compatible target (in our case this is the standard output).

This should give you the output of your timeline in form of a XML file. There are more formats available, such as JSON or RSS. I commited the lua file to my Git repository. I hope this will help others to get started using Lua on the web and / or using the Twitter API. There are a lot of chances in both of them. My plan is to use this tiny lua script and extend it to use it as a "full" twitter client ;-) ... Well a command line twitter client using Lua. Next step is to send a statud update from lua to twitter as so far this is only a request to retreive data. I also need to get into more depth using the LuaSocket module. Stay tuned if you are interested and please do leave a comment and / or feedback. Thanks!

Feb 16

Bing versus Google

I think around 2 years ago I had to write a paper at my university about SEO (Search Engine Optimization). Since then I check different search engines for their results from time to time. This time it was Bing (Bing.com) and Google (Google.com) - when I wrote the paper, Bing was still MSN Search or whatever its name was.

I use Firefox frequently and switch the search engine in the search box every once in a while. Recently I've been looking for the jquery homepage (www.jquery.com). So, this is what I did (for both search engines):

  1. Open search engine
  2. Enter keyword "jquery" without quotes

The expected result for me was http://www.jquery.com/ to be the first result on both pages - right? In my opinion this would be the most fitting result. Not for Bing I guess. It is on page 1, but it is only number 10 of the search results for me. Google displays the project homepage as result number 1 + Google has a link to the docs of jquery on number 2 of the search results.

Why is that so? What makes Bing think that the official homepage of a project is of less relevance than for example a wikipedia entry about it? Whose answer is 'correct'? In my opinion Google is more correct than Bing in this case and given it is a fairly simple example I wonder what actually causes the different results?

Would be nice to have some discussion on this topic in the comments - maybe you wanna add some of your search engine result differences.

Feb 10

8 ideas for Valentine's day 2010

Every year February the 14th is the so called Valentine's Day. Basically meaning giving love and / or presents to the one you love (my interpretation). My girlfriend and I don't think giving the opposite side a present is something useful, so we decided to just spend the day together and make it a fun day! I still have some ideas for presents that I want to share with you.

  1. Take him/her to a different city you both haven't been to. Short trips don't have to be expensive and can be a lot of fun.
  2. Take him/her out to dinner - not the usual subjects, try something like a dinner in a dark room (no light at all - you can't see anything, you can just feel and taste). There are a few restaurants offerings that - you should check in your area!
  3. Go to a cooking class together. This can be real fun. Making food yourself (I've heart Americans usually go out to eat) can be interesting, too. For example a Sushi making class - in case he/she likes Sushi.
  4. Invite him/her to a language class. Let's say like a 2hr class in a foreing language he/she is interested in. For geeks that would be a "Hello World" in Spanish, Japanese, Swedish, Finish, Russian ... whatever language you want to try.
  5. Cocktail mixing class. Learn how to make your own drinks. Don't try them and drive home if they are alcoholic, but knowing how a bar keeper's work is like, can be fun.
  6. Take him/her to the casino. Of course both have to be of the legal gambling age in your country, but it's a lot of fun.
  7. An iPod Shuffle with 'your' songs on it. Every couple has songs that 'belong' to their relationship. Put those on the Shuffle and give it to him/her.
  8. One of my favorite sites - animoto.com - offers a Valentine's Day special. Animoto combines your pictures and videos with music into a nice video. You could make a video of 'your last year' or something like that really easily. Try it out!
Well, those are the ideas I had for my girlfriend and me but as said - no presents for either of us. Maybe it helps other though.
Jan 20

Getting started with Lua

"Lua does not try to help you write programs with hundreds of thousands of lines. Instead, Lua tries to help you solve your problem with only hundreds of lines, or even less." This sounds pretty interesting right? Here is how I got started with Lua.

So lately I've come to the joy of joining a development team who uses Lua extensively, mainly as an embedded scripting language for C++. For me as a Java dev this sounded really interesting and so I started an expedition into the world of Lua and wanted to give a short introduction and a couple of links I found useful. Please note I am still just playing with Lua, haven't written that much code in it yet, but so far I can say: It's definately worth a try.

What's the first thing you do, when you take a look at a new language? Well at least I do: "Hello World" ;-) To actually see Lua in action you don't even have to download anything. lua.org offers an online demo for the language. So what does it take for a hello world?

print("hello world")

Yep, that's it. Easy, huh? ;-) Now what else can you do? Expand our example a bit, but before doing that I decided to get Lua installed on my Kubuntu VM. Fun story, it is already installed, so Ubuntu ships Lua with it. To start the Lua shell you just have to type

lua
. Now inside the shell you are able to basically do anything you want and just try things out, for example

original = "Check it out - this is one long text."<br />
changed = string.gsub(a, "long", "even longer")<br />
print(original)<br />
print(changed)

So this is an easy method to replace / exchange the contents of strings. Now what was new for me, there is no such thing as

String original
to declare original as a String. That saves you some time ;-).

You can put all of the code into a Lua file (ending with .lua) and then call this file using the Lua interpreter:

lua stringswitch.lua
. This will run it and print the two strings. Now the last thing I tried was expanding my hello world example to:

text = "Hello"<br />
name = io.read()<br />
print(text .. " " .. name)<br />

The two dots (

..
) append the following string to the leading one, So inside the
print
method Lua takes the
text
appends a whitespace to it and then appends the
name
. The result will be
Hello Stefan
if you enter "Stefan" when prompted for an input.

Those were my first steps in the process of getting to know Lua, so far I like it, it's fun to use and has nice and very important intuitive methods to offer.

Some links:
Lua.org - Official homepage
Programming in Lua - complete book online
The Lua online demo interpreter
My github repository for my lua learning path

Please feel free to comment, contact me with questions via email, twitter or in a different way. Would love to get some feedback and opinions on Lua.

Jan 07

3 rules to make twitter fun

I gues everyone knows about twitter: A social network to post messages of 140 characters or less. It's definately popular and there are no real rules as far as I know, so these are the rules I am following in order to keep twitter fun for everyone:

1: Tweeple are people, too!

2: Think before you tweet!

3: Read before you retweet!

If the used expressions are not familiar for you, check out Twitter dictionary and look them up if you will. I think they are pretty common already!