In debug and log messages, put the data at the end, not the middle.

May 27, 2007

In messages where a big string may be inserted, prefer “something something %s” over “something %s something”.

In this example, %s is a long hex-string representing an array’s contents.


[DECODE] [DEBUG] Was passed array ‘%s’ for processing


[DECODE] [DEBUG] Was passed array for processing: ‘%s’


[DECODE] [DEBUG] Function myDecodeFunc called with myArray = ‘%s’


Windows features you didn’t know existed: start /b and start /priority

May 12, 2007

In popular Unix/Linux shells, there is an option to start a process in the “background” by (i.e. in bash) typing “./something &“, or pressing Ctrl-Z and then “bg“. The process then prints its output to stdout as usual, but the bash runs in the foreground and receives console stdin.

In Windows, something similar (much less powerful than the bash “jobs”, though) can be done by doing: start /b something

Read the rest of this entry »

Python: Why to assign functions’ return values to dummy variables

May 12, 2007

In response to Kototama’s comment in the previous post:

There is a need, when running directly under the interpreter (code placed in the global namespace, not inside a function or method), to assign the return value of any function to a dummy variable.

Read the rest of this entry »

data: URI

May 11, 2007

(None of this works in IE – use Firefox.)

The data: URI is a type of URI that contains the data that is returned, in the URI itself.
Read the rest of this entry »

RealtimeCmd – hotkey for running cmd.exe in realtime priority

May 5, 2007

Sometimes your system hangs because some process enters a busy-loop that does evil things, like allocating huge amounts of memory and causing the swapfile manager to make Windows crawl. In those cases it would be nice to have something that runs in high priority that can kill the offending process. Microsoft addressed this by running winlogon.exe and taskmgr.exe in “High” priority, but that’s just not enough…

Read the rest of this entry »

Windows features you didn’t know existed: clip

May 5, 2007

    Redirects output of command line tools to the Windows clipboard.
    This text output can then be pasted into other programs.

Parameter List:
    /?                  Displays this help message.

    DIR | CLIP          Places a copy of the current directory
                        listing into the Windows clipboard.

    CLIP < README.TXT   Places a copy of the text from readme.txt
                        on to the Windows clipboard.

Python tricks: “Press Enter to exit” on unhandled exception

May 5, 2007

When I write Python scripts on Windows, I often write a main() function, and when it throws an exception I don't handle, the console window closes immediately before giving me a chance to look at the traceback.

Read the rest of this entry »