the corner office : tech blog

a tech blog, by Colin Pretorius


Mp3 died and nobody noticed.

I'm old enough to remember when people were buying new PCs and they were "powerful enough to play mp3s".

{2017.05.17 22:30} : Comments (0)

Flashing my Nexus 7

I did a complete re-install of my years-old Nexus 7 2012 this morning after it choked on an upgrade and got stuck at boot time. Notes for posterity:

Links and downloads:

  • instructions from this page.
  • adb and fastboot: Google now release 'latest' packages so dodgy scripts on the net are no longer needed (announcement, direct).
  • download images directly from Google (I went with nakasi 5.1.1. If it remains sluggish may go back to Kit Kat).


  • unzipped adb and fastboot into c:/android-sdk/platform-tools. I don't imagine location has to be that, but that's what the instructions said so I went with it

  • unzip image and make sure files are in same directory (ie. same dir as fastboot.exe).

  • reboot Nexus into boot loader (power off, then hold Volume Down while pressing power button).

  • plug in USB cable

  • open command prompt in the platform-tools dir.

  • run the following:

    fastboot erase boot
    fastboot erase cache
    fastboot erase recovery
    fastboot erase system
    fastboot erase userdata
    fastboot oem unlock 
    fastboot flash bootloader bootloader-grouper-4.23.img 
    fastboot reboot-bootloader 
    fastboot -w update
  • reboot into bootloader again

  • run

    fastboot oem lock
  • reboot.

Worked like a charm for me. Full output:

C:\android-sdk\platform-tools>fastboot erase boot
< waiting for any device >
erasing 'boot'...
OKAY [  0.080s]
finished. total time: 0.085s

C:\android-sdk\platform-tools>fastboot erase cache
******** Did you mean to fastboot format this ext4 partition?
erasing 'cache'...
OKAY [  0.116s]
finished. total time: 0.119s

C:\android-sdk\platform-tools>fastboot erase recovery
erasing 'recovery'...
OKAY [  0.026s]
finished. total time: 0.028s

C:\android-sdk\platform-tools>fastboot erase system
******** Did you mean to fastboot format this ext4 partition?
erasing 'system'...
OKAY [  0.558s]
finished. total time: 0.560s

C:\android-sdk\platform-tools>fastboot erase userdata
******** Did you mean to fastboot format this ext4 partition?
erasing 'userdata'...
OKAY [  7.542s]
finished. total time: 7.544s

C:\android-sdk\platform-tools>fastboot oem unlock
(bootloader) erasing userdata...
(bootloader) erasing userdata done
(bootloader) erasing cache...
(bootloader) erasing cache done
(bootloader) unlocking...
(bootloader) Bootloader is unlocked now.
OKAY [ 25.253s]
finished. total time: 25.256s

C:\android-sdk\platform-tools>fastboot flash bootloader bootloader-grouper-4.23.img
target didn't report max-download-size
sending 'bootloader' (2100 KB)...
OKAY [  0.275s]
writing 'bootloader'...
OKAY [  1.234s]
finished. total time: 1.513s

C:\android-sdk\platform-tools>fastboot reboot-bootloader
rebooting into bootloader...
OKAY [  0.015s]
finished. total time: 0.017s

C:\android-sdk\platform-tools>fastboot -w update
target didn't report max-download-size
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
archive does not contain 'vendor.img'
wiping userdata...
Creating filesystem with parameters:
    Size: 30080499712
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8160
    Inode size: 256
    Journal blocks: 32768
    Blocks: 7343872
    Block groups: 225
    Reserved block group size: 1024
Created filesystem with 11/1836000 inodes and 159268/7343872 blocks
wiping cache...
Creating filesystem with parameters:
    Size: 464519168
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 7088
    Inode size: 256
    Journal blocks: 1772
    Blocks: 113408
    Block groups: 4
    Reserved block group size: 31
Created filesystem with 11/28352 inodes and 3654/113408 blocks
Bootloader Version...: 4.23
Baseband Version.....: N/A
Serial Number........: 015d25785843f405
checking product...
OKAY [  0.031s]
checking version-bootloader...
OKAY [  0.017s]
sending 'boot' (5184 KB)...
OKAY [  0.662s]
writing 'boot'...
OKAY [  0.217s]
sending 'recovery' (5738 KB)...
OKAY [  0.736s]
writing 'recovery'...
OKAY [  0.238s]
erasing 'system'...
OKAY [  0.115s]
sending 'system' (649455 KB)...
OKAY [ 81.590s]
writing 'system'...
OKAY [ 36.336s]
erasing 'userdata'...
OKAY [  4.909s]
sending 'userdata' (139157 KB)...
OKAY [ 17.318s]
writing 'userdata'...
OKAY [ 12.632s]
erasing 'cache'...
OKAY [  0.089s]
sending 'cache' (9052 KB)...
OKAY [  1.141s]
writing 'cache'...
OKAY [  1.080s]

finished. total time: 157.261s

C:\android-sdk\platform-tools>fastboot oem lock
(bootloader) Bootloader is locked now.
OKAY [  1.430s]
finished. total time: 1.433s


{2017.01.08 13:02} : Comments (0)

Encoding is never fun

I noticed some weird behaviour with my blog app. I had a special character in one of my entries which was being converted correctly if I ran the blog builder app from my IDE, but didn't if I ran it from the command line (or more correctly, cygwin).

After some googling, I came across this SO post. The upshot is that Java's FileWriter is sucky and just takes the default encoding from your environment, and you always want an OutputStreamWriter with the encoding explicitly set.

Another subtlety is that using a CharSetEncoder will cause encoding exceptions to be caught and thrown, just specifying "UTF-8" as the argument for the encoding will cause exceptions to be suppressed.

You can also specify -Dfile.encoding=UTF-8 on the command line, although who wants to do that?

{2016.08.20 09:53} : Comments (0)


I saw this today, by accident: Bitkeeper's gone open source.

That's some irony, right there.

{2016.05.31 21:22} : Comments (0)


About an hour after posting the previous entry, I thought 'sod it' and decided to push some stuff, to wit: a util library and my blog software.

{2016.04.23 16:50} : Comments (0)

Git Hosting

I have a Github account, but there's (currently) nothing there. Mainly because I'm too lazy to clean up and review and publish code I don't mind being public.

I also have a BitBucket account, and there's (currently) nothing public there either. Mainly for the same reason that I don't have anything public at Github.

The difference being that I've recently started pushing private code to Bitbucket, because unlike Github, Bitbucket allows private repos for free.

Then today I came across GitLab. Now I have an account there too. It too allows private repos.

I'm a little old-skool and I'm still making peace with the idea of having my 'private' coded hosted externally. I mean, I still pre-encrypt my stuff before letting cloud backups do their own encrypting and syncing. But in reality, my 'private' code is stuff like Project Euler, and apps I use at home, which are generally a bit ugly or hard-coded for me. I don't want them shared by default but it's not the end of the world if they got 'leaked' in future. The main thing I gain is easy backing up of my code. Which I sort of have anyway with my encrypty-cloud backup, but restoring and accessing that isn't so easy.

The two other reasons for remote hosting are visibility (aka helping the world, and/or ego), and code management features.

As for 'visibility' - I think Github's still the only place to publish code, should you want your work to be seen. I'll get around to publishing stuff publically by default, eventually, since ... well, why not? Yet none of the pet projects I'm working on are likely to be of interest to anyone else in the world, and since I don't think anything I work on at home is necessarily CV-enhancing (beyond 'does he write crap code?'), I'm not that fussed about visibility.

Finally, code management features. Community features (patches, merges, etc) in Github are great, but I don't need them for private code. I'm curious to see what Bitbucket (and, probably, Gitlab) will give me. Issue tracking and the like? Code searching? CI (Gitlab, I think?). It'll be interesting to see what's useful and/or interesting.

{2016.04.16 09:47} : Comments (0)

Square roots

A fun diversion whilst trying to solve a Project Euler problem.

SO: Fastest way to determine if an integer's square root is an integer

Which also led to the history of the magical inverse square root in Quake3 code: Origin of Quake3's Fast InvSqrt()

{2016.01.21 22:29} : Comments (0)

MySQL files per table

Hrm: InnoDB File-Per-Table Tablespaces

{2015.12.26 08:55} : Comments (0)

Lost the arms race. Perhaps

I spoke too soon. Turns out my comment spam filter isn't as effective as it once was. Cue some cleaning up in the backing db and locking old blog posts. Let's see if that helps.

I like having a blog, but there are times when I find myself questioning the amount of time I choose to spend on it.

{2015.11.01 - 12:08} : Comments (0)


I'm doing what I threatened to do, even though I'm sure there a million other pet projects I'd rather be faffing with. I'm rewriting my blog. The servlet app is going, and in its place something which does the static file thing. Except that I like having comments support and what I currently have works relatively well at keeping auto-spammers away (despite being a noddy solution). So I want to keep that bit as a simple servlet app. And that means dynamic updates of pages on a server, which means it's static pages but a process taking care of things.

{2015.10.30 - 22:18} : Comments (0)

« Older


main blog


rssfeed posts

© Colin Pretorius