9 Sept 2012

Understanding code

You don’t understand a piece of code until you can confidently add features to it.

Is screen the only advantage tablets have?

Quite often, I find myself wanting to read on my Nexus 7 than on my laptops.  Checking my Google Reader, reading any article that’d take more than a couple of minutes, reading Kindle books... I prefer the tablet for all these.  This is not surprising because the Nexus 7 has a 216-dpi screen while my laptop has an incomparable 96-dpi screen.

When it comes to doing some real work... work that involves multitasking and/or precision, touch devices are very inadequate.  Think of writing code, for instance.  I’d have 6+ browser tabs open with various manuals, one terminal for building and running the code, one or two more terminals for other random stuff, one editor/IDE window (usually GVim; occasionally Eclipse), and a few more browser tabs that are pure distraction (Gmail, Google+, etc.)  A touchscreen device without overlapping windows just won’t work for this use case.

Android’s multitasking UI would improve over time, but I doubt if it can catch up with current desktop OSes in the next two years.  On the other hand, it’s likely that before the end of 2013 there will be enough high-res monitors and laptops in the market.  When that happens, I may use the laptop a lot more frequently than the tablets.

While tablets may replace laptops for quite a few people going forward, I don’t see myself giving up the functionality I get from desktop OSes.

2 Sept 2012

Inspecting 302 HTTP headers

Let’s say you want to inspect the response header for an HTTP request.  But the response is a 302, so your browser immediately navigates to the new location and you never get to see the 302 response (and the headers).

One way to solve this problem would be to install a browser extension that would keep the headers for you even after the redirect has happened.  But I’m not a big fan of installing browser extensions for functionality that I very rarely need.  So I use the wget command instead:
wget -S -O/dev/null --max-redirect=0 'http://www.google.com/'
-S flag tells wget to print the headers to stderr
-O/dev/null discards the response body (by writing it to the null device)
--max-redirect=0 tells wget to not follow any redirects.

This is the 302 redirect google.com sends for redirecting users to country-specific Google domain:
--2012-09-02 09:54:33--  http://www.google.com/
Resolving www.google.com (www.google.com)... 74.125.237.50, 74.125.237.48, 74.125.237.52, ...
Connecting to www.google.com (www.google.com)|74.125.237.50|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 302 Found
  Location: http://www.google.com.au/
  Cache-Control: private
  Content-Type: text/html; charset=UTF-8
  [...snip...]
  Date: Sat, 01 Sep 2012 23:54:33 GMT
Location: http://www.google.com.au/ [following]
0 redirections exceeded.

28 Aug 2012

Some monospace fonts

Being the monospace font freak that I am, I recently found PT Mono and have fallen in love with it.  Turns out, I’ve been liking the PT family of fonts for a while: I have been using PT Sans for this blog’s headings.  You can download PT Mono (and others) for free from ParaType’s web site.

If PT Mono is my newly found attraction, I have been really liking Envy Code R for its extreme readability.  If I had to pick a single monospace font to live with for the rest of my entire life, I’d choose Envy Code R.  You can download Envy Code R for free from Font Squirrel.

If you’re into serif monospace fonts, give Verily Serif Mono a try.  This used to be my favourite font until I stumbled upon Envy Code R.

30 Jul 2012

Poor battery life after Android 4.1 (Jelly Bean) update?

If your Android phone was recently updated to Android 4.1 (aka Jelly Bean) and you have been seeing really bad battery life ever since, read on.  It could be that Google+ sync has been enabled by the update and that’s using up a lot of power.  Go to your phone’s Settings > Accounts > Google settings screen.  For every Google account listed, deselect the Google+ option.  This should bring back sane battery life to your phone.

See Demystifying Android power usage for more generic tips on saving battery life on Android devices.