14 January 2010

Colourizing mercurial output when piping to less

Filed under: Uncategorized — Tags: — bookweevil @ 10:43 am

From at least version 1.3.1 onwards, it looks like mercurial will colourize the output of commands like “hg diff” (for instance), making them much easier to read on-screen.

However, when it detects that output is going to a pipe rather than a terminal, it normally turns colourization off.

You can turn it back on using the “–color=always” argument; and if you’re piping to “less”, then “less -R” will cause it to recognize ANSI colour escape sequences. For example:

  hg diff --color=always | less -R

7 June 2009

Recovering a misconfigured or mis-flashed Linksys WRT54G from Windows XP

Filed under: router configuration — bookweevil @ 4:23 pm

Here’s the steps I took to restore the Linksys firmware to my (probably just misconfigured) WRT54G router after a failed attempt to upload third-party firmware – basically, the steps are summarised from the dd-wrt recovery page.

You’ll need a known good firmware image in .bin format (e.g. WRT54GV4.0_4.21.1_US_code.bin from the Linksys site), and your PC should be connected to your router via one of the ethernet ports.

  1. First see if a hard reset fixes the problem (power off, wait a bit, power on, hold down the reset button for 30 secs).
  2. Assuming it doesn’t: configure your PC to assign itself a static IP address for the relevant network interface – e.g.
  3. In a command prompt window, run the following command:
    ping -t -w 2

    This continually pings the target address, with a timeout of 2 milliseconds.

  4. In another command prompt window, go to the directory where your firmware image is located. Type the following, but do not hit enter:
    tftp -i PUT <name of firmware image file>
  5. While keeping an eye on window 1 (with the ping command running), power off the router, then power it back on. While the router is off, ping obviously will have no route to the destination. But within a couple of seconds of turning it back on, you should see a response – e.g.:
    Reply from bytes=32 time=9ms TTL=255

    As soon as you see a response – perform the actions in step 6.

  6. In the window with the tftp command ready to be run – hit the Enter key. tftp may take a while (a minute or two, at 10 Mbps) to upload an image – but hopefully it will complete, and report that the transfer was successful:
    Transfer successful: 3122208 bytes in 55 seconds, 56767 bytes/s

If it doesn’t work, there’s a variation you can try: configure your network interface to use a lower speed. In “Network connections” (from the Control Panel), right-click on the relevant connection and select “properties”. Click the “Configure …” button near the top right. Select the “Advanced” tab. The exact setting you’ll have to change then depends on the exact hardware and driver you’re using, but for mine, theproperty to change is “Speed & Duplex”.

Advanced settings for a network interface

Advanced settings for a network interface

It should be set to “Auto” or something similar. Set it to “10 Mbps half duplex” and try tftping again. (Remember to set it back once everything’s working again!)

5 May 2009

Some literature on considerations of morality in economic theory

Filed under: Uncategorized — bookweevil @ 7:11 pm

Beckert, Jens, Bettina Hollstein, Edward W. Lehman, David Marsden, and Amitai Etzioni. 2007. Amitai Etzioni – Twenty years of ‘The Moral Dimension: Toward a New Economics’. Socioecon Rev (December 4): mwm021. doi:10.1093/ser/mwm021.

Bowles, Samuel. 1998. Endogenous Preferences: The Cultural Consequences of Markets and Other Economic Institutions. Journal of Economic Literature 36, no. 1 (March): 75-111. doi:10.2307/2564952.

Farina, Francesco, Frank Hahn, and Stefano Vannucci. 1996. Ethics, rationality, and economic behaviour. Oxford University Press.

Harsanyi, John C. 1955. Cardinal Welfare, Individualistic Ethics, and Interpersonal Comparisons of Utility. Journal of Political Economy 63, no. 4 (January 1): 309. doi:10.1086/257678.

Hausman, Daniel M., and Michael S. McPherson. 2006. Economic analysis, moral philosophy, and public policy. Cambridge University Press.

Rabin, Matthew. 1998. Psychology and Economics. Journal of Economic Literature 36, no. 1 (March): 11-46. doi:10.2307/2564950.

7 March 2009

button text disappearing in firefox

Filed under: useful — bookweevil @ 12:24 am

If you fiddle around with some firefox settings while developing extensions, this can result in HTML buttons no longer having any text in them.

In Stu’s post here, “No button text in Firefox”, he suggests you ensure that the following lines are uncommented in prefs.js in your profile [or you could set the options to false using about:config]:

user_pref("nglayout.debug.disable_xul_cache", true);
user_pref("nglayout.debug.disable_xul_fastload", true)
user_pref("nglayout.debug.enable_xbl_forms", true)

Experimentation reveals it’s the third one, .enable_xbl_forms, which causes the problem – but I’m not sure how it got set. (An article at the mozilla developer centre, “Setting up extension development environment“, recommends enabling the first of these, but not the others.) It’s possible some developer add-on enabled it, or that I just clicked on it accidentally in about:config.

6 March 2009

when converting flv files to mp3’s with vlc, mp3’s are at half-speed

Filed under: audio conversion, Uncategorized — bookweevil @ 10:52 pm

The solution is here (and here)…

“I added samplerate=44100 to the transcode section of my parameter string and the speed is back to normal!”

I also found I had to encapsulate the output as mp4, and then re-convert the mp4 to get raw mp3.

So the parameter string used by VLC ended up being:


28 March 2008

Getting updatedb on cygwin to prune paths with spaces

Filed under: cygwin — Tags: — bookweevil @ 8:12 pm

On cygwin, updatedb often gives “Permission denied” errors (e.g. for “C:/System Volume Information”) andFile name too long” errors (e.g. for files in “/cygdrive/c/Documents and Settings/MyName/Local Settings/Temporary Internet Files”).

And attempts to use the “–prunepaths” option to avoid indexing these seem not to work due to the spaces in the filenames. But there is a fix … From the Cygwin mailing list comes the following tip — you can type something like

  updatedb  --prunepaths='/proc  /cygdrive/c/Documents.and.Settings/MyName/Local.Settings/Temp'

to avoid these — prunepaths accepts regular expressions, including the use of a dot (.) to represent any character including a space.

My fix looks something like the following (line breaks inserted for legibility):

updatedb  --prunepaths='/proc /cygdrive/c/program_disk/cygwin










 /cygdrive/h '

19 January 2008

backup annoyances with rdiff-backup

Filed under: backups, tech, windows — bookweevil @ 10:58 am

Ugh. Ran into problems with rdiff-backup — it fails trying to remove files (which it added perfectly well) which are over some length limit.

Have decided that rdiff-backup in Windows (probably mirrors in general, too) is just a bad idea: it’s too flaky, and when it fails it leaves your repository in an unrecoverable state. Better to backup to a single archive file I suppose, at least it won’t get corrupted. Will check out dar and duplicity instead.

8 October 2007

bug in partimage on ubuntu with lvm installed

Filed under: bugs, ubuntu — bookweevil @ 12:10 pm

Hm … when I run partimage interactively, I get the message “/dev/dm inode doesn’t exists [sic]”.

It appears that partimage’s method of detecting partitions (namely, reading /proc/partitions) is not compatible with Ubuntu’s way of doing things. (more…)

7 October 2007

AMQ (another misattributed quotation)

Filed under: Uncategorized — bookweevil @ 11:38 am

Dr Samuel Johnson, of dictionary fame, is widely quoted as having said “God Himself, sir, does not propose to judge a man until his life is over.” But in fact, Dale Carnegie appears to have invented the quote, in How to Win Friends and Influence People.

20 September 2007


Filed under: quotes — bookweevil @ 10:18 am

Ironically, Ralph Waldo Emerson’s famous quotation on quotations is usually misquoted or quoted out of context. The original is “Immortality. I notice that as soon as writers broach this question they begin to quote. I hate quotation. Tell me what you know.” (Journals (1822–1855), May 1849 — see for instance wikiquote.) It’s mostly quoted as “I hate quotations. Tell me what you know.”

Older Posts »

Create a free website or blog at