Recovering data from my Android Tablet

So Super Wipe Lite had completely decimated the data partition of my Asus Eeepad Transformer TF-101 Android tablet, effectively wiping out all my photos. Here’s how I managed to get them back.

Hopefully this blow by blow account of my data recovery effort may help anyone who finds themselves in a similar predicament. The results of your recovery largely depends your old data still being intact and not yet overwritten by new data.

First, some prerequisites.

  1. Your tablet needs to be rooted. If you’re tinkering around with partitions getting formatted, there’s a good chance you’ve got root too.
  2. Some sort of terminal emulator that allows you to do dd. I used Terminal Emulator.
  3. PhotoRec software on your desktop.
  4. An external storage drive large enough to contain the partition that you’re recovering from. I had an old external HDD that I hooked up to the Transformer via the USB port on the keyboard dock.

An overview of the procedure.

  1. We’ll make a raw dump of the wiped partition so we can perform the recovery from a desktop computer.
  2. We’ll use PhotoRec to do a low-level scan of the data to look for signature of files, and recover them.

Now step by step:

Part I: Low-level copy of the partition

1. On your android tablet, open Terminal Emulator.

2. Go superuser by typing su. Grant SuperUser permissions to the Terminal Emulator when prompted.

3. Type mount. This lists all the partitions on your system. Look for a line that says something like /data, which was the folder that contained all my lost data.

/dev/block/mmcblk0p7 /data ext4 rw,nosuid,nodev,noatime,user_xattr...

Basically we’re wanting to find out what the corresponding block device is. In my case, it was /dev/block/mmcblk0p7

4. From that same list, you can also figure out where your external HDD is mounted. Mine looked something like this:

/dev/block/vo1d/8:5 /Removable/USBdisk2/Drive3 tntfs rw,relatime, uid=0...

If the partition you’re wanting to recover is larger the 4GB, make sure you use something like NTFS or ext3/4. FAT simply won’t cut it.

5. With all the information gathered above, we’ll do a the dump like this

dd if=/dev/block/mmcblk0p7 of=/Removable/USBdisk2/Drive3/transformer-recovery.img

Sit back and relax for a moment. Mine took around 20 minutes for a 15GB dump. When it is finished, you’ll be returned to the prompt.

Part II: Recovering the files using PhotoRec

1. Now that we’ve got a low-level copy of the partition, plug the external hard drive into a desktop computer where you can run PhotoRec.

2. Fire up PhotoRec. Because PhotoRec is only able accept actual partitions as targets for low level scanning, we’ll play a trick where we point it at the partition containing the image file transformer-recovery.img.

3. When asked about the filesystem type, pick ext2/ext3.

4. When asked if all space needs to be analysed, pick Whole.

5. Finally pick a folder where you’d like the recovered files to be stored.

In a nutshell, what we’ve done is imprinted all the low-level information from the block device in the Transformer to an external HDD, and used PhotoRec to scan through and pick up any file signatures it’s able to find.

Hope this guide has been a help.

Vocalizing compliments

Here’s something that I’ve been learning and experimenting with since I started working in and amongst a team of software developers. While the principle isn’t limited to software development teams, it comes up quite obviously because of the measurable nature of the work that we do.

Take every opportunity to celebrate and compliment good work.

Opportunities to diss incompetance are a dime a dozen. Instances where good work peeks it’s little head out and waves timidly are few and far between. Times when one genuinely identifies and appreciates good work are even rarer. (Pretentious shoe polishers need not apply)

The compliment needn’t be overcomplicated or elaborate. Just make a statement about what you appreciate. Some examples:

“Dude, that component you put works really well.”
“Jimmy, really love the docs you wrote on that library.”
“Hey Bill, you gotta see what Steve just did. It’s freakin’ cool.”

With software, no one wins for being vague and kind: a defect is a defect, and git commit messages never lie. But a seized opportunity to praise good work is a beautiful thing.

Deploying a webapp? subdomain it

I’ve been migrating domains from an old server to a new one that we’ve just acquired. Some were really straightforward standalone CMS setups, so a tar xcf and an scp followed by a mysqldump and a mysql < database.sql sufficed.

But there were ones that had multiple webapps running off the same domain. I had a Piwik installation on http://example.com/analytics, then a random dokuwiki setup running at http://example.com/wiki. While it’s all too easy to simply create a subfolder and dump the files in, a setup like this makes incremental migration very difficult. When you cut over the DNS records for the domain from an old IP to a new IP, everything needs to work at the first try.

A better way is to have each webapp run in a seperate subdomain. Instead of http://example.com/analytics, set it up at http://analytics.example.com/. Instead of http://example.com/wiki, set it up as http://wiki.example.com/. Sure it’s a few extra steps when setting up, but  decoupling your webapps is good practice.

When it’s time to move one of the webapps to its own server, or migrate your domain incrementally, you can simply copy over all the files for that one webapp, repopulate the database tables, do a test run using your HOSTS file, then flip the switch at your DNS server when you’re ready. The big win? Everything else on http://example.com/ continues to hum along swimmingly.

How to fake French, Italian and Malaysian English accents

After sitting in on 3 days of Symfony training conducted by French native, I’ve started to pick up a bit of a French accent in the way that I speak.

I’ve always been curious languages, especially the European ones. Usually learning the actual language is difficult, and there is no one to practice it with, so the next best option is to emulate their accents when speaking English.

While there are many aspects and nuances that one needs to watch out for when attempting such a feat, I’d like to share my findings as far as accents go. It’s of particular intrigue for me because of how simple the rules can be, and how effectively it works.

To accent a syllable in a word is to say it louder, or more prominantly than the its sibling syllables. Because accenting is relative to the other syllabi in the word, it doesn’t really affect single syllable words.

Try saying:

When travelling on public transportation in Melbourne, you should always carry an umbrella.

In typical British/American, it is a bit of a mish-mash, but it would go something like this.

When travelling on public transportation in Melbourne, you should always carry an umbrella.

For a French accent, stress the second syllable of every word:

When travelling on public transportation in Melbourne, you should always carry an umbrella.

For an Italian accent, stress the second last syllable of every word:

When travelling on public transportation in Melbourne, you should always carry an umbrella. Spaghetti marinara fettucinni raviolli.

Speaking English like a Malaysian is much harder, but there is a pattern still. The accents are the same across the syllable, but you rely on melody to group the words logically. With the melody, you generally have 3 notes (do, re, mi). The rule: you start low, end your words and phrases with mi.

Examples:

orange (re mi)
origin (do re mi)
original (do re mi mi)
originally (do re mi re mi)
originality (do re mi re mi mi)
an origin (do do re mi)
the original plan (do do re mi mi mi)

So, you will say:

when travelling on public transportation in Melbourne, you should always carry an umbrella.

Cheers!

Dealing with on-coming pedestrians while cycling

Cyclists generally know how to indicate their directional intentions a vehicle behind. If one wishes to turn left, one raises and extends one’s left arm till it is horizontal. Likewise when one wants to turn right, except one would use one’s right arm.

But how does one indicate to on-coming pedestrian traffic. Raising either arm will result in a most certain confusion. For example, does the raising of one’s arm serve as an instructional “please modify your path of travel and head in that direction”, or is an informational “That’s where I’m headed, please get out of the way”.

This is an uncertainty that is hard to resolve in the average time that stands between a cyclist and an on-coming pedestrian. It often results in said pedestrian freezing in a less than ideal position, requiring the cyclist to perform a high-speed maneuver to the unpleasant soundtrack of said pedestrian spouting expletives.

No, there is a better way.

When approaching a pedestrian, you first attempt to make eye contact. Thanks to evolution and a general love for life, pedestrians are wired to pay very close attention to sudden and quick motions, making this the easiest step. An exception would be a growing number of people who pedestriate around with their eyes glued to their mobile devices. Not to worry, they’re sufficiently distracted, are quick to admit to being in the wrong, and that they should be more attentive to their surroundings while commuting.

Step two. Once you’ve made eye contact, you need to produce a stare that says “Hey you, yes you! I’m talking to you. pay attention now”. This takes a bit of practice because you’re not allowed to mouth the words. All you have are two eyes and a network of facial muscles to get the message across. Don’t care for coming across rude for this instance, matters of safety trumps courtesy.

Step three, after a firm channel of communication has been established, drop the eye contact abruptly and proceed to look assertively towards the route that you intend to take. Do not use your arms, do not re-establish eye contact to see if the pedestrian got the message, do not go in any direction other than the direction that you’ve look-dicated.

Here’s what this sequence of actions should communicate.

  1. Hey you, pay attention to me.
  2. I know you’re there, I’m not going to tell you where to go, but here’s where I’m headed.
  3. Now that you know where I’m headed, you’re free to decide what you’d like to do.

As the bigger commuter and the one who is able to call the shots in this split second relationship, it is the cyclist’s solemn duty to cause as little inconvenience as possible to his/her co-commuting pedestrian friends. The rule of thumb is to pick a path around the pedestrian, and use the above techniques to assure said pedestrian that he/she is not required to change directions.