A Windows console that does not suck

We’ve all been there: You’re used to the terminal on Linux or OSX, and then for some or other reason you need to work on Windows and you’re confronted with the half-baked monstrosity that is cmd.exe:

It’s 2011 and this is Windows 7: Why does the console still make me want to gnaw off my fingers?

To summarise: You can only resize the window vertically (so you’re always restricted to 80 characters width which is just idiotic on modern widescreen displays), copy and paste is so painful that you’ll wish that they’d rather just not bothered with it in the first place and the cmd.exe interpreter itself is primitive when compared with any modern unix shell.

Enter the two-pronged solution of Console2 and Git bash! Console2 is a console that solves the UI problems (resizing! copy and paste! terminal transparency! tabs!) and you can use it together with any combination of command line interpreters, such as for example the existing cmd.exe, bash or anything else.

Here’s my setup, configured with Git bash (you get this for free with the Windows git installer, for this purpose it’s better than Cygwin as it’s a touch closer to Windows) as well as plain old cmd.exe. To configure a Git bash tab, set Shell to “C:\Windows\SysWOW64\cmd.exe /c “”C:\Program Files (x86)\Git\bin\sh.exe” –login -i” (including all quotes) and Startup dir to %HOMEDRIVE%%HOMEPATH%. I’ve also configured Ctrl-Alt-T to invoke Console2. With shift-mouse-drag I can select text (nice editor select, not cmd.exe block select, ptooey!), and I’ve set Ctrl-Shift-C and Ctrl-Shift-V to copy and paste so it’s like the Gnome terminal on Linux. Behold:

Console2 makes the pain go away.

My Windows experience is a lot more bearable now, perhaps even slightly pleasant! Did I just say that?!


  • PowerShell replaces cmd.exe, but by default still runs inside the Windows console. Still much suckage in other words, plus that I don’t feel compelled to learn PS yes.
  • Cygwin mintty is also often cited as a console replacement, but seems to cause problems (for example with git) as it’s not a full Windows console.
  • Cygwin itself is really fantastic, but due to that POSIX compatibility layer which is otherwise a useful thing, differs too much from the native Windows goodies so that sometimes native Windows behaviour is interfered with.

How to stop accidentally answering or declining calls when trying to fish your HTC Sense Android phone from your pocket

As you know by now, I really do love my HTC Desire Z phone. However, besides the miserable battery life which one tries to live with because it’s otherwise such a kickass phone, a major gripe was HTC Sense’s vertical swipe to answer or decline an incoming phone call. This has resulted in me accidentally answering or declining numerous incoming calls as I was trying to fish the phone out of my jeans pocket, as this fishing generally causes one’s fingers to slide vertically over the screen. The advice of turning the phone around so the screen faces one’s leg also doesn’t cut it, because the screen could get scratched on the various small studs one often finds in that area, but more importantly because I don’t like following semi-working rules like that.

I finally found a forum posting by a user named deetsvl with a solution to this problem that I’ve confirmed works perfectly on this HTC Desire Z. Behold:

All hail WidgetLocker, solution to the HTC Sense accidental answering problem!

WidgetLocker going to cost you a whole € 1.41, but it does the trick just perfectly, if you remember to change the following setting: In “Settings | Popups”, check “Hide Incoming Call”. When you receive a call, you’ll have to slide horizontally first to unlock WidgetLocker, then the normal vertical business for answering / declining a call. If you manage to do that accidentally, I know a good side-show agent, so give me a call. On my Desire Z, I also checked “Settings | Buttons & Inputs | Slide Keyboard Unlock” so that I don’t have to unlock Widget Locker when suavely flick-sliding open the keyboard on this baby.

I hope that you enjoy your new-found only-answering-and-declining-calls-that-you-really-want-to freedom!

Ubuntu 11.04 Natty Narwhal Annoyances (Dell E6410 with NVS 3100m GPU)

I recently upgraded my Dell E6410 with NVS 3100m GPU laptop from Ubuntu 10.10 (Maverick Meerkat) to 11.04 (Natty Narwhal), and I can’t shake this feeling that the distribution has taken a few steps back. I’m not even referring to the new Unity desktop, but to some super-irritating annoyances I had to fix or work around before being able to use the system. These annoyances were not present in 10.10, it had a whole different collection. 🙂

Wireless N connects, but no packets get through

The first annoyance was when I successfully connected to my wireless N access point, but couldn’t get a single packet through. After much searching, it turns out there’s a bug in the firmware for the Centrino Advanced-N 6200 wireless adapter that keeps it from getting any data through.

The solution is to disable wireless N on your laptop by creating a file etc/modprobe.d/inteldisablen.conf with the following contents:

options iwlagn 11n_disable50=1 11n_disable=1

and then to reboot. If you don’t want to reboot, just rmmod and modprobe the iwlagn kernel module. I’ve confirmed that this fix works.

Google Chrome scrolls excruciatingly slowly

After resuming and suspending, certain 2D and GPU-assisted graphics operations slow down. Scrolling in Chrome, even on a simple Google results page, is excruciatingly slow with head-explosion-levels of lag.

The solution is to disable hyperthreading, or at least to disable a number of CPU cores, at suspend and re-enable at resume. My laptop i5 CPU has 2 real cores, and thus 4 virtual cores due to hyperthreading. I’m using the following script, taken from this forum thread to do the necessary core disabling / enabling automatically:


# Disable hyper-threading processor cores on suspend and hibernate, re-enable them
# on resume. Presumably helps for buggy nvidia behaviour.
# save this file as /etc/pm/sleep.d/20_core_i5_disable_cores and make excutable
# with chmod +x /etc/pm/sleep.d/20_core_i5_disable_cores

# from: http://www.nvnews.net/vbulletin/showthread.php?t=158091

case $1 in
                echo 0 > /sys/devices/system/cpu/cpu1/online
                echo 0 > /sys/devices/system/cpu/cpu3/online

                echo 1 > /sys/devices/system/cpu/cpu1/online
                echo 1 > /sys/devices/system/cpu/cpu3/online

I’ve confirmed both the slow-down behaviour and the working of the fix.

Eclipse scrollbars don’t work

Natty’s new overlay scrollbars screw with Eclipse’s scrollbars, leaving you with 100% non-working scrollbars! You can either disable the overlay scrollbars completely, or comment out the GDK_NATIVE_WINDOWS line close to the start of the /usr/bin/eclipse shell script:


On my setup, this fix works most of the time.


It’s a shame that these things don’t work out of the box, as some of them had been reported long before the Natty release. Before I forget, if you install 11.04 on this specific laptop, you might also have to follow my Ubuntu 10.10 howto if you see a black screen at bootup or resume.

The Django Book 2.0 in MobiPocket / Kindle format

I wanted to read the web preview of the Django Book’s second edition on my Kindle. Besides the fact that all image links are broken on that website and have apparently been so for some time, I prefer to have these things in the DRM-free MobiPocket / Kindle format. Of course I couldn’t find this anywhere, so I rolled my own based on the book’s SVN repository.

On this page you can download the MobiPocket version of the book and the HTML source files I generated to make it. You can also read on for the skinny on how you can do this yourself.

This procedure works best on a unix-like machine, as we’re going to use grep and sed along with some Python.

1. We start by doing a checkout of the reStructuredText sources of the book, moving the linked graphics into the same directory as the reStructuredText txt files and then creating a grepindex.txt file that will serve as the basis for our table of contents index.txt:

svn co http://djangobook.com/svn/branches/2.0/ 20svn
cd 20svn
find graphics/ -name *.png -exec mv {} . \;
grep -h "^Chapter [0-9]*:" *.txt > grepindex.txt

2. The grepindex.txt will now be converted to something more reStructuredText-like using this script, called grepindex2index.py:

# first do:
# grep -h "^Chapter [0-9]*:\|^Appendix [A-Z]:" *.txt > grepindex.txt
# then:
# python grepindex2index.py grepindex.txt > index.txt

import re
import sys

rst_header = """
The Django Book 2.0

Copyright 2006, 2007, 2008, 2009 Adrian Holovaty and Jacob Kaplan-Moss.
This work is licensed under the GNU Free Document License.

This ebook version was prepared by Charl Botha <http://charlbotha.com/> from
the SVN at http://djangobook.com/svn/branches/2.0/ on 2011-04-25, and is
hosted by <http://vxlabs.com/>.


def main():
    f1 = open(sys.argv[1])
    print rst_header

    # this will match on "Chapter 10: the title" or "Appendix B: another title"
    # groups 0: chapter 10 or appendix A; 1: 10 (or None), 2: A (or None), 3: title
    pat = re.compile('(^Chapter\s*([0-9]*)|^Appendix\s*([A-Z])):\s*(.*)$')
    chapters = []
    appendices = []
    for l in f1:
        # Chapter 10: Advanced Models -> `Chapter 10: Advanced Models <chapter10.html>`_
        mo = pat.match(l)

        if mo.groups()[1] is not None:
            chapters.append("* `Chapter %s: %s <chapter%02d.html>`_" % (mo.groups()[1],mo.groups()[3],int(mo.groups()[1])))

            appendices.append("* `Appendix %s: %s <appendix%s.html>`_" % (mo.groups()[2],mo.groups()[3],mo.groups()[2]))

    print "\n".join(chapters)
    print "\n".join(appendices)

if __name__ == "__main__":

Save this to a script called grepindex2index.py, then invoke it with:

python grepindex2index.py grepindex.txt > index.txt

3. We’ll then proceed to fix all chapter references with the following bit of sed:

sed -i "s/\.\.\/\(chapter[0-9]*\)\//\1.html/g" chapter*txt

(this will change all “../chapter??/” links to just “chapter??.html”)

4. Everything is now ready to be converted to HTML:

for i in *.txt; do rst2html $i `echo $i | cut -f 1 -d .`.html; done

5. After downloading this django desktop background as cover image, I dragged and dropped the top-level index.html file onto the free Calibre software to import it, and then used the edit metadata function to set the cover image. After this, I converted the imported files to MobiPocket remembering to add the word “appendix” to the chapter detection xpath expression in the “structured detection” section of the conversion dialogue.

That’s all there’s to it! Have a good read.

Don’t buy HomePlug / Powerline ethernet adapters

(Post summary: The real-world throughput of current generation Homeplug AV 200 Mbit/s powerline ethernet adapters in a modern house is woefully inadequate. Even wireless is much to be preferred, and can be had for cheaper. Read below for why.)

Based on the superb price / performance ratio of the MSI ePower 200AV II kit as extolled by this comparative review (32 powerline adapters were tested), and especially the fact that in the test setup these adapters managed to attain 32 Mbit/s even in the bad case scenario (two different circuits, 100 metres of cable separating the two adapters), I purchased the MSI ePower 200AV+ II kit to replace a wireless link I currently have in my house between the second and third floors. Based on iperf measurements, the wireless link currently manages around 22Mbit/s of throughput. Because the two power sockets I was planning to use are on the same circuit, I thought that I could improve on this existing connection with the two powerline adapters. Little did I know…

The MSI ePower 200AV+ kit still nicely in its box.

After taking delivery of the new kit, I started testing with both adapters in the same room. One thing that can be said for this hardware, is that it’s really plug and play. One adapter in wall-socket and connected to first floor ethernet hub, second adapter in wall-socket and connected to my laptop, and my laptop was online. No mess no fuss.

The first nasty surprise appeared as I installed and started up up the software that came in the box (version 5.0). It claimed not to find any homeplug adapters on the network, although the laptop I was running it on was directly connected to one of the PLCs. So I downloaded version 6.0 of the software, only available in German, from MSI’s website and that did manage to see both adapters. At least now I was able to configure both the PLCs (in German…) and set the network name to something private for security’s sake.

After moving one of the adapters to my study on the third floor and connecting it to a Linux server there, I could start running iperf on the server and my laptop on the second floor for testing. The two PLC adapters were now in the same-circuit sockets I was intending to use. Below is the output of three runs of iperf:

C:\Users\cpbotha\Downloads>iperf -c
Client connecting to, TCP port 5001
TCP window size: 8.00 KByte (default)
[148] local port 49921 connected with port 5001
[ ID] Interval       Transfer     Bandwidth
[148]  0.0-10.0 sec  10.7 MBytes  8.95 Mbits/sec

C:\Users\cpbotha\Downloads>iperf -c
Client connecting to, TCP port 5001
TCP window size: 8.00 KByte (default)
[148] local port 49987 connected with port 5001
[ ID] Interval       Transfer     Bandwidth
[148]  0.0-10.0 sec  11.2 MBytes  9.41 Mbits/sec

C:\Users\cpbotha\Downloads>iperf -c
Client connecting to, TCP port 5001
TCP window size: 8.00 KByte (default)
[148] local port 49988 connected with port 5001
[ ID] Interval       Transfer     Bandwidth
[148]  0.0-10.0 sec  10.4 MBytes  8.70 Mbits/sec

Yes ladies and gentlemen, that’s an absolutely miserable 9 Mbit/s (think 1 Mbyte/s…) between two MSI ePower 200AV+ II adapters on the same circuit, on different floors in a house that was built 5 years ago. For your reference, my wireless link (two Sitecom 300N X2 access points in Wireless Distribution Mode) easily manages 22 Mbit/s effective throughput right through a reinforced concrete floor.

MSI’s own utility claimed the following (I’ve cut out things that you don’t need to see):

Rate 18/39
Vendor Atheros
Firmware INT6400-MAC-4-0-4011-00-3430-20090501-FINAL-C
Übertragungsrate hoch 174.00
Übertragungsrate niedrig 15.00

… with its reported link speed varying between 17 and 35 Mbit/s.

I tried the third floor PLC adapter on various different sockets, the results were similarly depressing.

As if the miserable throughput was not reason enough to avoid powerline adapters, note the following mechanical issue:

When the adapter sits in a double socket, the only thing that’ll fit in the free socket is a really thin plug as the upper part of the adapter is flush with the socket and covers a fair part of the other hole.

As you can see in the caption, although the PLC has a socket of its own, it covers the neighbouring socket in a double-socket setup to such an extent that you can only fit a really thin plug in the neighbouring socket.

To conclude: Homeplugs perform really well in a test environment, even when different circuits are introduced and metres of extra cable are inserted. However, what the tests often fail to take into account, is the fact that people actually make use of other electrical devices besides homeplugs (!!) and that these all introduce noise into the home grid that apparently severely affect powerline ethernet performance. Perhaps in your house things work out differently, but my advice would be to steer clear of powerline adapters (unless you can borrow a pair to test with), opting of course for ethernet cables whenever this is possible and for wireless otherwise.