Page Up and Down on Mac terminal

Press Shift-Fn-Up to have the Mac terminal send the shell PgUp key and Shift-Fn-Down for PgDn.

Page Up and Down on Mac terminal

Windows 7 Devices and Printers window doesn’t load

From some point, Devices and Printers window of my Window 7 64-bit doesn’t show anything, with the green bar going on forever. It turned out that this is because I stopped Bluetooth Support Service of my box to secure a bit of memory. I had to enable it back and everything works as expected.


Windows 7 Devices and Printers window doesn’t load

Some Python subprocess.Popen tips

subprocess.Popen non-blocking pipe I/O using an additional thread and an asynchronous queue:

Why subprocess.Popen fails on Windows with a command having a Unicode filename within it: it internally uses CreateProcessA, which is the single-byte character version of CreateProcess, meaning that it won’t handle Unicode characters correctly. For this to be correctly handled, the command line, and hence the filename contained, needs to be encoded with the file system encoding, that is usually MBCS.
This thread and the pep below describe exactly this problem as well as the workaround above mentioned.

You will need to specify the encoding of the Python file if you use Unicode characters there: most simply add # encoding=utf-8 as the first or the second line of your source code although there are some more degrees of freedom, which can be found here.

Some Python subprocess.Popen tips

Create an audio CD image on Mac

On Mac, it is easy to create a CD image using Disk Utility. On recent versions of Mac OS, however, it is disabled to create images of audio CDs—the function is grayed out in the menu when you insert an audio CD. In order still to create an image from an audio CD, there are a couple of ways on the command line.

1. hdiutil

hdiutil is the command line version of Disk Utility. Run the following command to create the CD image:

hdiutil create -srcdevice /dev/diskn -format UDTO image.iso

Replace n with the correct disk number, which can be found using diskutil:

diskutil list

2. dd

dd is a low-level file copy utility which is oblivious of the type or the content of file. As in Unix-based OS every device is a file, you can copy a “file” corresponding to a drive to a normal file:

dd if=/dev/diskn of=image.iso

You will need to unmount the drive before copying it:

sudo umount /dev/diskn


When creating an exact copy of a (data) CD/DVD using Disk Util, select the “device” instead of the “folder” within the device. And use DVD/CD-R master as the format.

By default, Mac assigns the file extension of .cdr, which is exchangeable with .iso.

If you want to create a cross-platform data CD image using hdiutil:

hdiutil makehybrid -iso -joliet -o image.iso /input/path


man pages, e.g., man hdiutil or

Create an audio CD image on Mac

Mouse wheel scrolling with GLUT on Mac OS X

In order to use wheel scrolling event with GLUT on Mac, you should patch the GLUT source code and compile it. The Mac-version GLUT source code is available here on Apple’s developer website. After unzipping, modify or patch the source code appropriately referring to this page. In my MacBook Pro running Lion, I had to use the old Xcode 3 to compile the code. I modified the project settings so that it uses GCC 4.0 as the C/C++ compiler instead of the default GCC 4.2, and rolls back the base SDK to the old Mac OS X 10.5. Then I release built the code and replaced the resulting framework with the existing /System/Library/Frameworks/GLUT.framework after making a backup of course ;).

Now it should send the mouse *up* events having button values of 3 or 4, respectively for wheel up and down.

Mouse wheel scrolling with GLUT on Mac OS X