Salvaging a deleted message from Thunderbird

undeleteSuppose you got an important mail, but by accident deleted the message – and to make matters worse, you also decided that emptying the mailbox was a pretty neat idea. Is then time to Panic?

Well it might, but there is a chance you might be able to undelete the message – and quite easily if you’re on a Mac or a Linux machine. Here are the few steps, which has helped recover a lost mail or two… First close Thunderbird. Then located the mail directory (on Linux it’s located in the subdirectory .mozilla-thunderbird in you home directory – on windows most likely somewhere in C:\Documents and Settings\*\Application Data\Thunderbird – In there you’re looking for the “Local Folders” directory.

If you’re on a Mac or Linux type the following:

cat Trash | grep -v X-Mozilla- > Restored

The cat command prints all the line in the file Trash – not to the screen, but as input to grep. Grep is used to find all lines not begining with “X-Mozilla-“ and prints these – and the greater than makes the print go to a new file called Restored.

Once this is done exit the directory and restart Thunderbird. You should now be able to find a new folder called “Restored” and a lot of old mail. Find the message you need to restore, and drag it into the inbox or wherever you need it – then delete the “Restored” folder.

If you’re on windows you need to do a little more work. The trick happening with the command line above, is that all lines beginning with “X-Mozilla-” is deleted and thus restored from their deleted state. A suitable editor might do the trick.

Do notice, that the Trash folder may be quite large, if you haven’t run the “Compact Folders” in quite a while – and if you did do that after deleting the message you’re trying to restore, then it’s probably gone for good.

Ubuntu: Changing your IP number

Sure it doesn’t happen that often, but sometimes you might need to change the IP number of your machine running Ubuntu. Either to configure it with a static IP number on your LAN or temporarily to configure a Wifi router – the latter being my case.

The first shot at changing the ip number, was going to the “System” menu, choosing Administration and Network Tools. It sounded just about right – but it’s wrong. Sure you view settings and some statistics, but it’s all read only.

ubuntu-network-connectionsSo, if you want to change the IP number, go to your top panel (in the right side, you’ll find you network icon. Right click on the icon and choose “Edit Connections”. In the window opening, you’ll have access to changing the ip number – to manual configuration, DHCP with ip number only or (as is default) full DHCP configuration.

Choosing “Automatic (DHCP) addresses only” allows you to get an automatic IP, but use openDNS’ DNS-servers – should you prefer them over the DNS servers provided by your ISP.

Android – installing apps

Picking up from the last post, I’d share a little more of my Android experience.

Once I had configured the phone with my basic settings – voicemail number, wifi networks and so on – and moving my contacts to the phone, installing software is probably the next step. There is an Android market, but it’s just as good (or bad) as the Apple Apps store – finding the best applications may be a pain.

Schack has been on Android for awhile, and here are the tricks, that got me started fast. First install the program called “barcode scaner” (just that no more). You do that by launching the “market” and searching for the name click and install it. It allows you to scan barcodes with the camera on the back of the Hero.

Next step is going to the Cyrket website on any computer and use the big screen and keyboard to explore the software available for Android – once you see something you like, you can scan a square barcode on the page and go directly to the page on the market place – so much easier than browsing on the Hero itself.

Some of the programs I’m playing with currently include:

  • nav4all – GPS Navigation
  • Listen – PodCasts (subscription and downloads)
  • NewsRob – RSS reader with Google Reader integration
  • Compass – name says it all…
  • Toggle Settings – nice, but wasn’t available in the Market.
  • TasKiller – a task killer

Bonus wifi tip for HC Hero: If your wireless network is hidden, it seems the Hero really doesn’t play well. Make the Wifi net visible and you should be all good (and if the network is secured probably, it shouldn’t be a problem it’s visible).

Moving to Android (mobile)

I’ve been using SonyEricsson mobile phones ever since the launch of the P800 some years ago – all with the Symbian OS. Until a few days ago that is. Now I’m on Android. I’m still in the process of finding my way around Android, but I’ll try to post some of the tips and tricks of running Android here. This first post covers the very basics.

The Phone

My Android phone is the HTC Hero. It seems well build and solid – and the case seem to be crammed full with just about any imaginable feature available in a mobile phone. The only exception seems to be an FM radio, but frankly I doubt I’ll miss it much. I didn’t really use it on my most recent P1i.

The phone has a MicroSD card (easily accessible) and included with the phone was a 2Gb card. It is a regular MicroSD card. The Hero supports MicroSDHC cards, which are available in sizes up to 16Gb currently (but the format should support up to 128Gb).

TODO: It seems it would be worth while to get hold of a SDHC card (Class 6) to replace the included card. Android uses the MicroSD card as swap storage and faster memory card ought to result in faster performance on the phone…

Moving contacts

I’ve been using mobical for years to backup my contacts. I don’t think Andriod and mobical work together, so moving contacts over was a slight detour, but it worked almost without any pains. As a part of setting up the Andriod phone, you tie it to a Google Account. I’ve tied it to my personal Gmail box on my on Google Apps domain – as it works just fine.

To get contacts to the phone I logged into mobical and exported all contacts in a single VCF-file (it Contained a Vcard for every contact). Then I logged in to my Gmail Webmail and choose contacts in the left side menu and imported the file.

It went surprisingly well. Most of the overlapping contacts was merged with out any issues and a few duplicates had to be merged (or removed) by hand. A few minutes after updating the webmail contacts, they were automatically synced to the phone.


TIP: If you like the phone to pop-up an image of the caller, you can add images to contacts in the webinterface. Use Facebook, Linkedin or regular image search on Google to find suitable images for your contacts. For companies (main number) I usually pick their logo as contact image.

Filling a select drop-down with ajax data using jQuery

In user interfaces, it’s sometimes the case, that you need to have dropdowns with content dynamically loaded from a database, and sure you can query the database and place the content in the HTML-source as regular markup, but you can also write a few lines of jQuery powered javascript, and provide the data from an ajax-source.

Here’s how to do it.

First make the drop-down and as the single option make a “loading” message – just to let the user know something is happening.

1
2
3
<select id="dropdown">
        <option value="-">-- loading --</option>
</select>

Next make a few lines of javascript, which runs once the page is ready, and let that initiate the json request (and fill out the drop down with the require values).

1
2
3
4
5
6
7
8
9
10
11
<script type="text/javascript">
$(document).ready(function() {
        $.getJSON("select_ajax.php",{}, function(data){
                       var options = '<option value="">-- select please --</option>';
                       for (var i = 0; i < data.length; i++) {
                                options += '<option value="' + data[i].value + '">' + data[i].label + '</option>';
                       }
                       $("select#dropdown").html(options);
        })
});
</script>

For convenience there’s a simple example available here. The example uses a static array as source, and in all practical uses this would probably be replaced by a database query.

Browser handling of broken includes in an Ajax world?

In this mordern web 2.0 age, javascript includes are used more and more – and in some cases solutions often depend on included content from 3rd parties. While it is nice these 3rd parties may provide us with data (such as the latest tweets from twitter), it would be quite nice, if issues on their server didn’t break the fancy page we’re building.

So the question is this: If you build a page and include javascript from foreign scripts, will error messages on their part break your site? We’ve made the assumption, that the Web2.0 page will degrade gracefully, so that the content/functionality of the javascript-includes is just extra frosting, not needed to use the page

We did a simple little test, and in the most common browsers, a server error (that is an errror signaled in the http-header status code), will just cause the browser to ignore the included content. If the header is a “200 Ok” header, the content will break.

The answer, no – assuming, that their servers provides a http-header, that signals error. If you have a few spare seconds, please visit the test page, and if your browser reports a javascript error, please leave you browser (make and model) and operating system in a comment below.

Building image tags with jquery

Like tables, jQuery also allows you to play around with all other tags. In a recent project, we wanted to change a fixed set of labels/texts into icons instead. For this challenge jQuery was used to build the new image tag, and for good measure, here is a small example of how you can build an image tag – including alt-text and click-event.

The basic code for building and inserting an image into the DOM looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
<div id="image"></div>
 
<script type="text/javascript">
$(document).ready(function() {
 
  $image = $('<img>').attr('src', 'image_polar.jpg');
  $image.attr('alt', 'Polar bear');
  $image.attr('height', '200').attr('width', '300');
  $image.click(function () { alert('You clicked the image'); });
  $image.appendTo('#image');
 
});
</script>

The code above creates a new image tag. Adds an alt-text and sets the height and width (resizing the image in the browser). Finally it attaches a click-event and inserts the image into the DIV-tag named “image”.

(se example)

jQuery and tables

I’ve been playing with jQuery the recent weeks, and while it is reasonable simple to get started with and the jQuery documentation is pretty good, I thought I’d share a few snippets of jquery examples/code, which showcases a few simple practical uses for jquery.

First up – tables and jquery.

With jQuery you can add content to a HTML table. Here are to simple examples on how to add content into a table.

First let’s see how you add a row with two cells to a table:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
<table id="tableOne" border="1">
 <thead>
  <tr><th>Col 1 </th><th>Col 2</th></tr>
</thead>
<tbody>
</tbody>
</table>
 
<script type="text/javascript">
$(document).ready(function() {
 
  $tableBody = $('#tableOne tbody');
 
  var $tableRow = $('<tr>');
  $('<td>').text('Row 1 Cell one').appendTo($tableRow);
  $('<td>').text('Row 1 Cell Two').appendTo($tableRow);
  $tableRow.appendTo($tableBody);
 
});
</script>

(se example).

Let’s build a slightly more advanced example and add data to a table from a javascript array.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<table id="tableOne" border="1">
 <thead>
  <tr><th>Table Header</th></tr>
</thead>
<tbody>
</tbody>
</table>
 
<script type="text/javascript">
var sampleData = new Array('One', 'Two', 'Three', 'Four');
 
$(document).ready(function() {
  $tableBody = $('#tableOne tbody');
 
  for (var row = 0; row <= sampleData.length-1; row++) {
    var $tableRow = $('<tr>');
    $('<td>').text(sampleData[row]).appendTo($tableRow);
    $tableRow.appendTo($tableBody);
  }
});
</script>

(see example).

Extending the second example and drawing the data populating the table from an ajax-source should be pretty simple. Have fun and enjoy jQuery.

Flight Control

flight-controlI really like simple games, which you can play where ever you are – and which still has enough challenges to be interesting for quite a while. One of the best games I’ve played for a long time is Flight Control for the iPhone/iPod Touch. The game was developed by Firemint.

It’s a fairly simple game. You’re in control of an Airport and all you have to do is make sure the planes land at the runways. To do this you simply draw their designated paths on the screen. There are 4 different aircrafts – helicopters, propeller planes, small jets and large jets. As you play more planes concurrently enters the airspace – and eventually it gets quite busy and avoiding mid-air collisions a challenge.

In the recent update of the game two new airfields was added to the original, and with the different layouts, new strategies for keeping the planes from hitting each other must be developed.

The sound in the game is nothing special, but that really doesn’t matter – once the airspace gets busy you really don’t have time to listen – and if you like you can disable sounds when the game launches and keep listening to podcasts or music.

The game is currently (at the time of writing) on sale for 99 cents – buy it now (AppStore link) and you’ll have hours of entertainment.

My Current high scores:

  • Classic: 153
  • Hawaii: 91
  • Carrier: 82

Better but Broken

Working with application development – either on the web, on the desktop or any other place – is often quite interesting. When making new releases features are added, changed – or in rare cases removed.

As a developer – or “software product manager” – it must be an interesting challenge to keep up with the users and the market to capture the features and changes to a product, which will make it better from release to release.

There are probably many ways to try to keep up – by doing research and by listening to user feedback seems to be two obvious choices, but I’m sure, there are many others. Some, I’m sure is also just a gut feeling of what might be cool new features. If you’re good – and now the users, the market and the competitors, you’re making steady progress.

Yet sometimes you miss. The slow adoption rate of Microsoft Vista might be a sign of a very public miss.

It doesn’t have to be a big miss, to chase a user away.

picture-1This weekend it happened to one of my favorite iPod Touch games – Tap Defense was upgraded to version 2.0 – and while most of the updates probably are great, there’s one little detail, which probably ensured I’ll rarely play it again (unless I find a way to fix it).

I used to play Tap Defense a lot while listening to Audiobooks and Podcasts. The new version has been updated with sound effects and music – and now the podcast or audiobook goes away (pauses) when the game is launched.

I’m sure TapJoy, developers of the Tap Defense game, are proud of their new sounds, but if I need to choose between the game and my listening to podcasts, the game looses. Please bring the ability to keep listening to what every the iPod plays, back in version 2.1.