How to build a web service in 8 hours

I was a big fan of Jaiku (here I am) and didn’t “get” Twitter until about a year ago when a friend showed me Tweetdeck. Aha! So that’s how you’re supposed to use it! Not through the web page twitter.com but by using a third party tool. I got so excited that I proclaimed Twitter the future of the web.

And I stopped using Jaiku.

One thing I did miss from the Jaiku-days, though, was the long discussion threads under each “jaik” (the Jaiku version of a “tweet”). Here’s an example. This provided Jaiku with depth, something you can hardly accuse Twitter of.

So an idea emerged: what if you could build a web service that made it possible to comment and discuss each tweet just like you did in the Jaiku-days.

Thus, Discuss a Tweet was born.

Or, well, at least the domain was registered. I did this April 17 2009. It then ended up in my pile of great-ideas-I-should-one-day-implement and nothing happened.

Until… last weekend.

I knew that it would be possible to put it all together quite fast. I had used Disqus when we built Rate My Pitch during 24 hour business camp – so I knew that the commenting system, the most difficult part, I would get for “free”. I wouldn’t even need a database. It was all about putting things together in a slightly new way. A classic mashup.

So, I started hacking away. A couple of hours later, the result is a mashup of the following services:

This is just a tiny little hack but I think it serves as a good example of how modern web development is done. You pick bits and pieces from all over the web, some open source components, some embedded web services. You put things together and something new emerges.

I used PHP and this is also worth noting. People complain about PHP but one of its biggest strengths is its user base and size. When you’re doing a mashup such as Discuss a Tweet you can be sure someone else has done about the same things you need and there is code out there ready to be used. You can’t say that about Scala or Erlang regardless of how powerful and beautiful the languages are. (Things are changing of course as the popularity of the language grows.)

Another thing happened while Discuss-a-Tweet was in my idea-pool: Google Buzz launched. According to Mr Jaiku himself, Jyri Engeström, Buzz is the continuation of Jaiku. And, yes, it allows you to comment and discuss tweets.

Maybe a usage pattern is emerging in how we use different social networks. Twitter for quick news updates and cool links, Facebook for our friends and Buzz for the discussions. Maybe the Opportunity Cloud for a service such as Discuss-a-Tweet is dispersing. We’ll see. It was fun building it anyway – and it only took a few hours after all. :)

(PS. Follow me on Twitter.)

Posted in Software | Tagged , , , | 1 Comment

Mobile Development SDKs compared: MoSync, PhoneGap and AppWhirl

Ever since I started my first consultancy business back in 1998, I’ve been thinking “next year will be the Year Of Mobile”.

I’ve been wrong every year.

Of course the sales of mobile phones have been great but in terms of mobile applications and the mobile web, things were more or less stuck in black & white text mode. But, the last couple or years, things have finally started to change – and change fast!

So, it is a very good time to get in to mobile development. This is like the early days of the web all over again. Opportunities are plenty! Before you know it, every company will want a mobile application to accompany their social web site. If you don’t know mobile yet, now is the time to start learning.

The obvious first question is: where do I start?

There are many mobile development tools out there. This blog post is a little deeper look in to three different approaches that will give you an app running in less than an hour.

By far the simplest approach is taken by tools such as AppWhirl. This is an online tool that generates a complete application for you. Not only that, it sends the app to the Apple App Store for approval. That’s right, AppWhirl is only for iPhone.

It is also extremely limited in that you can only generate apps from existing RSS feeds, making it less of an application toolkit and more of a mobile RSS reader-generator. Nothing wrong with that, you just need to be aware of the limitations.

AppWhirl is:

  • Extremely simple to use – anyone can generate an application with this tool.
  • Extremely limited – this is not an application SDK but a very simple way to publish your RSS feed as an application.
  • Only supports iPhone.

PhoneGap is far more advanced. This is how they describe themselves:

PhoneGap is a development tool that allows web developers to take advantage of the core features in the iPhone, Android, BlackBerry, and Symbian with a unified JavaScript API.

Now, while PhoneGap is a cross platform tool, the development process and setup is slightly different for the different platforms. You need to install all the different SDKs to fully use this tool. This can be quite a hassle.

What is PhoneGap? It’s basically a bridge that enables Javascript to call native functionality not normally accessible to a web page running in a browser. It does this by packaging the PhoneGap framework, your HTML/CSS/JavaScript-files and a magic JavaScript-file called “phonegap.js” in an application package. It then uses the built in browser component to render the “pages” of the app.

This means if you’re used to web development you will be up and running quickly on PhoneGap. It also means you can use nice frameworks such as JQuery for that AJAX mojo.

Unfortunately the documentation wasn’t exactly up to date so I had some problems getting things up and running on my Android Developer Phone. If this is the same on the other platforms, you’re in for a couple of hours of tweaking settings and installing SDKs and googling around for fixes if you want your app running on more than one platform.

To summarize, PhoneGap is:

  • Cross platform, works on many devices – but will require setup for each.
  • Web developer friendly. People familiar with HTML and JavaScript will feel right at home.
  • Capable but still limited by browser. With the upcoming HTML5 PhoneGap will become really interesting, though!

Next in line is MoSync. (First a disclaimer: I have worked for the company behind MoSync.) The platform recently became open source and received an investment from none other than the MySQL founders, Michael “Monty” Widenius and David Axmark. Like MySQL, MoSync is based in Stockholm.

You don’t need to install any other SDK than the MoSync IDE to get started. Programming is done in C++ which means you will feel at most at home if you’re coming from the embedded or gaming world. In fact, MoSync can run legacy games like Castle Wolfenstein just fine:

(That’s me speaking in the background, by the way.)

So far, MoSync is Windows only (although the IDE is based on Eclipse) so Mac- and Linux-users are out of luck. Supported platforms include Symbian S60, Java ME, Moblin and Windows Mobile. Android, iPhone and Maemo are “coming soon”.

MoSync is cross platform but obviously you won’t get more features than the underlying platform supports. Best support you’ll get for basic graphics, sound, simple Bluetooth access and networking. Without a doubt the best feature of all is the promise of one codebase, multiple platforms, but your mileage may vary.

MoSync is:

  • Cross platform, works on many devices – Android and iPhone “coming soon”.
  • C++ based, suitable for porting old embedded apps to native but a little higher barrier to cross for the beginner (but C++ isn’t that difficult).
  • Still a bit untested, MoSync needs a few more success stories that proves their claims.
  • One codebase, one tool!

All in all, three completely different approaches to mobile development. Which one suits you? Well, that’s for you to decide. They all have their strengths and drawbacks and I think it will be quite obvious for you which one fits your bill.

Now, get out there and create great stuff for mobile!

Updated: MoSync just announced Android support.

Updated 2: David Wood wrote an overview of some other cross platform tools.

Posted in Software | 4 Comments

Flash Lite to Java Midlet in 10 seconds

I am currently helping Sony Ericsson as a community manager for their developer site. As part of this I’m blogging over at blogs.sonyericsson.com and just recently I wrote a short post on how to convert swf to jar for mobile phones.
In case you didn’t know, Sony Ericsson has a framework embedded in most of their newer phones called Project Capuchin, making it possible to run a Flash Lite application inside a Java midlet. Quite cool, actually.

Posted in Software | Tagged , , , , , | Leave a comment

Firefox 3.5: huge step forward

This article sums up all the new features in Firefox 3.5. An amazing list! HTML5, local data storage, vastly improved font support, location aware browsing and a bunch of new CSS-features are some of the highlight features.
Adding it together sums up to a new web platform unlike anything we’ve seen before. The step forward is so big there will be web services written exclusively for Firefox 3.5. With a growing market share there’s certainly a user base big enough for developers to go Firefox-only.
The web vill look vastly different in about a years time thanks to Firefox 3.5. Exciting times! Download a beta here.

Posted in Software | Tagged , , | Leave a comment

How to become a good programmer

The blog CodeLathe offers some advice. This is true, and in line with the subtitle of this blog:

Programming is purely a mental activity and has no relationship to any physical activity including typing. To become a better programmer, you will need to exercise and build up the part of the brain that deals with managing complexity and dealing with the relationships between countless objects.

Learn to manage complexities. That’s the core of programming. Add human communication to that and you have software engineering.

Posted in Software | 1 Comment

SEO-friendly titles in Wordpress with Atahualpa theme and Headspace plugin

The Atahualpa theme for Wordpress is a really powerful theme with lots of settings. But it doesn’t give you full control over the titles of posts and pages the way the Headspace plugin does.
How the titles of your blog posts look like is important for search engine optimization. If you want your post to be higher ranked in the search result (and who doesn’t?) the title is one of the most important factors to consider.
The Atahualpa theme and the Headspace plugin doesn’t work together without a minor modification to one of the helper php-files in Atahualpa. Look in the functions directory of the theme for the file called bfa_meta_tags.php. Open it in an editor and look for the line that says:

<title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>

Change it to:

<title><?php wp_title(''); ?></title>

Now you can enable the Headspace plugin and go to Settings -> Headspace and define exactly how your titles should be generated.

Posted in Software | Tagged , | 4 Comments

Building a working web service in 24 hours – straight


Happy business campers!

It’s the middle of the night and I’m in a big hallroom full of people all of them hacking on their computers.

The event is called 24 hours Business Camp and the goal is to bring 90 entrepreneurial people together and have them build a service in 24 hours.

There are 52 teams (although it’s not a contest, there’s no winner) and the ideas are ranging from tampon subscriptions to Youtube wrappers.

Building a service in such an extremely short timespan has been (is, there’s still 9 hours left!) a learning experience, primarly about the importance of focusing on what’s really important.

A little too tired to write anything more right now but let’s just say that without my framework of choice, JBoss Seam, I wouldn’t have been as productive as I have been. A couple of hours have been lost doing stuff like configuring Apache proxies on my server or fixing Hibernate errors. Still, it’s really amazing how much you can do with all the frameworks and open APIs out there. Everything is in turbo speed compared to a couple of years ago.

But now I should get some sleep.

Posted in Software | Leave a comment

Copying a VirtualBox VDI file running Ubuntu Server and getting Drupal running

Sigh. Things are never as easy as you want them to be. :)

I have two computers on my desk. My MacBook and my Asus EEE B202 running Windows XP. I wanted a development environment for Drupal (a php content management framework), so I tried running PHP on my MacBook.

It worked fine, but the first problem appeared when I tried to run Drupal. The PHP GD library was missing (used by Drupal for graphics). This is a known problem and requires a recompilation of PHP. The problem is, the Apache web server installed on the MacBook is used by OS X and may change in future updates to the OS by Apple. It also seemed a bit cumbersome to get it all to work as it should. So, I figured, why not in stead run a virtual machine with a developer setup in linux and get a clean separation between my day to day OS (OS X) and my developer server.

I decided to use VirtualBox, a free software provided by Sun, and run it on my XP machine (the B202). I installed Ubuntu Server 8.10 on the virtual machine.

If you haven’t used a software like VirtualBox or VMWare before, I can only say that it’s much easier than it sounds like. If you can install an operating system you can use VirtualBox. It’s a very slick and easy to use program.

But, there are of course a few problems.

The first problem was that Ubuntu Server was also missing PHP GD (not because of VirtualBox of course, but still). This time I only needed to do a:

apt-get install php5-gd

and voila, Drupal was running.

Now everything should have been fine and dandy if it hadn’t been for the bluescreens that suddenly started to occur on my EEE-box. After running VirtualBox and Ubuntu Server for a couple of minutes, maybe half an hour, XP decides to just crash. This happened over and over again.

Finding the cause of a bluescreen is never fun but it was clearly due to the VirtualBox setup.

But, hey, I’m in the virtual world here. So, I simply copied the .vdi-file (the file that VirtualBox uses to store the operating system on – it’s like a virtual hard drive) to my MacBook and set up a virtual machine with the vdi-file.

Everything worked as it should, except networking (I’m using hosted networking, making the virutal machine appear just like a third computer on my network – very neat, when it works).

The problem is that, although the environments are similar, the virtual network adapter gets a new MAC address. So, the Ubuntu OS gets confused and can’t find the network adapter. This is easily fixed by simply deleting an autogenerated file:

rm /etc/udev/rules.d/70-persistent-net.rules

and rebooting.

Now I have Ubuntu Server 8.10 running on my MacBook. I don’t have any desktop environment set up, making it rather slim (I use 384MB RAM and the full OS only takes about 1,5GB hard drive space). You probably want something like Webmin to make configuration a bit simpler. Here are instructions for setting it up.

Now, let’s just hope my MacBook doesn’t bluescreen.

Posted in Software | Tagged , , , , , , | Leave a comment

Setting up PHP and web server on OS X 10.5 (Leopard)

Your shiny Mac comes preinstalled with a web server and php but you need to set it up to get going. Starting the web server is as easy as enabling “Web Sharing” under networks settings. I did this but the server did not respond at http://localhost. So, what was wrong?

Well, I recently upgraded my hard drive to a 500GB version and I used Time Machine to restore my operating system. The problem is that this is not a clone of my previous setup but a copy and it leaves out certain files that Time Machine ignores to save space. One of those folders is the apache web server log folder which is required by apache at startup. Unfortunately OS X doesn’t tell you anything about this error when you enable Web Sharing, it just doesn’t work.

Anyhow, simply create the folder:

sudo mkdir /private/var/log/apache2

and you’re good to go. You might have to disable and enable Web Sharing again to restart the process.

So, now the web server is running. What about php? Edit the apache config file located at /etc/apache2/httpd.conf and remove the ‘#’ (comment) from the line that says:

LoadModule php5_module

Now you can test that it works by adding a file called helloworld.php to the folder /Library/WebServer/Documents. Add the following code snippet to the file:


< ?php
echo 'Hello World!';
?>

And point a browser to http://localhost/helloworld.php. Now three things can happen. 1) no response. Did you restart the server? 2) The exact content of the file is shown in the browser. This means the PHP module is not loaded. Make sure the httpd.conf file has the comment character removed as described above and then restart the web server by disabling and then enabling web sharing again. 3) Hello World! (and nothing else) is printed in the browser. Success!

The next step is probably to set up MySQL. Here are some resources for doing that. Good luck and happy PHP hacking.

Posted in Software | 1 Comment

Upgrading RAM memory on Asus EEE B202, Eee Box

A short video I made showing how to replace a memory chip on the Asus EEE B202 desktop computer:

Read this post for further details on how to perform the surgery. Removing the side cover was the most tricky part but putting it back together was done in a snap:

The B202 supports 2 GB RAM and has two sockets. I only use one socket with a 2048MB DDR2 PC2-5300 667MHz memory module.

The B202 is a nice little machine. Cheap, virtually silent and with low power consumption but still fast enough to use as a developer machine.

Posted in Software | Tagged , , , , | 2 Comments