Saturday, June 16, 2018

Building SBCL on Windows with Cygwin

I use Cygwin64 and the MinGW cross compiler to build SBCL installers on MS Windows. Here are the steps I follow (provided you have the necessary build environment in Cygwin and the WiX Toolset installed):
  1. Edit src/runtime/Config.x86-64-win32
    • Change gcc to x86_64-w64-mingw32-gcc
  2. export CC=x86_64-w64-mingw32-gcc
  3. sh
  4. sh
  5. Find the installer MSI file in the output directory.

Friday, November 10, 2017

Using OpenGL ES 2.0 with SDL2 via ANGLE

It turns out that the newest SDL2 version (2.0.7) has some special hint support for using the ANGLE library on Microsoft Windows as your OpenGL ES 2.0 library.
  1. Build SDL2 and ANGLE.
    • One oddity that you may need to account for is that SDL2 and ANGLE each use a different C run-time library by default, so you'll probably want them to agree.
  2. Put your libraries and DLLs in the appropriate spots.
    • For ANGLE, it makes sense to link directly to libGLESv2.lib so that all of our symbols are defined, but you can do the usual shenanigans with function loading from either the libGLESv2 DLL directly or from SDL_GL_GetProcAddr();
  3. When trying to use OpenGL ES 2.0 from SDL2 on MS Windows, these lines are the magic ones:

Thursday, June 22, 2017

Microsoft Visual Studio 2017 Command Line

The command line batch files have been moved... The new location for vcvarsall.bat and friends is:
  • C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build
Of course, you could always just go to the Start Menu and use
  • Visual Studio 2017 →  Visual Studio Tools → Developer Command Prompt for VS 2017

Monday, January 30, 2017

Simple Web Server

I needed to stand up a simple web server to test some WebGL code. It turns out that if you just need a basic HTTP server, Python has you covered in their standard library! You just run the following from what you want to be your web root folder:

python -m SimpleHTTPServer

Thursday, November 12, 2015

C-u M-x align

For years I've always been aligning columns of code by hand. GNU Emacs has a way to do some of this automatically. For example take this:

int m_myInt;
bool m_myBool;
std:string m_myString;

And use "C-u M-x align" to turn it into:

int         m_myInt;
bool        m_myBool;
std::string m_myString;

Friday, October 9, 2015

The Xorg fixed font

I've often wondered what exactly the "fixed" font is. Turns out that it is just an alias to whatever you want it to be (or whatever the maintainer decides it should be). On Fedora 22, the font alias file is kept at /usr/share/X11/fonts/misc/fonts.alias and the very first line of configuration says:

fixed    -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1

Friday, February 27, 2015

how slime enables debug info in sbcl

This is a copy-and-paste of an old Reddit post of mine.


Peter Keller (psilord) and I were talking about debugging CL and it prompted me to take a quick tour of how SLIME enables debug compilation for SBCL. This appears to be the general flow:
  1. C-u C-c C-k calls slime-compile-and-load-file (slime.el) with the default argument of 4. The default of 4 threw me. I don't know the history behind that.
  2. slime-compile-and-load-file (slime.el) generates a compute policy of '(cl:debug . 3)
  3. slime-compile-and-load-file (slime.el) calls slime-compile-file (slime.el) with arguments of (t '(cl:debug . 3))
  4. slime-compile-file (slime.el) calls the CL function swank:compile-file-for-emacs (swank.lisp)
  5. compile-file-for-emacs (swank.lisp) calls swank-compile-file* (swank.lisp)
  6. swank-compile-file* (swank.lisp) calls swank-compile-file (swank-sbcl.lisp)
  7. swank-compile-file (swank-sbcl.lisp) calls compiler-policy (swank-sbcl.lisp)
  8. compiler-policy (swank-sbcl.lisp) calls (sb-ext:restrict-compiler-policy 'cl:debug 3)

Sunday, February 22, 2015

Using LaTeX on FreeBSD

I've been using FreeBSD 10.1 on my laptop and had to relearn how to do some basic things in LaTeX. First of all, tetex is no longer a distribution that is used; look for "texlive" when installing. Secondly, I could not remember how to add local packages to my hash. After dusting many cobwebs, it appears to be the following:
  1. mkdir -p ~/texmf/tex/latex
  2. cp whatever.cls ~/texmf/tex/latex
  3. texhash

Friday, November 14, 2014

21st Century C

I am reading the book 21st Century C and am learning all sorts of new things. For me personally, here are some highlights and/or discoveries I made directly from the text or because I was poking around after reading the text:

  1. There is such a thing as C11 (and it's awesome). Where have I been?!?
  2. Cygwin is more useful than I realized.
    • While I knew that you could easily install a cross compiler, I didn't realize that you could easily install libraries for the cross compiler using ./configure --host=x86_64-w64-mingw32
    • Cygwin's gdb works with both the Cygwin executables and the MinGW executables.
    • There is a native-GUI version of GNU Emacs called emacs-w32. This would allow one to use the excellent Emacs GDB support with the baked-in Cygwin paths.
  3. GCC has a flag for that
    • I've used -Wall and -Wextra, but I should have also been using -Werror
    • -pg for profiling with gprof (I didn't realize there was even a profiler!)
    • -fprofile-arcs -ftest-coverage for coverage with gcov
  4. Embedding text into a script is called a here document.
  5. pkg-config does a lot of the work for you for CFLAGS and LDFLAGS. Note that Cygwin's MinGW cross compiler has a separate pkg-config executable.
  6. GDB tips and tricks.
    • I've used gdb here and there, but didn't know that in addition to 's' for step and 'n' for next, there is 'u' for "until the next line forward from this." Seems like that would be really helpful for iterating through loops.
    • There is useful syntax for printing arrays, i.e. 'p *array_name@10' to print a dereference of the 10 pointers from array_name
    • You can define macros to easily print structures that you work with. Save your macros in .gdbinit in your home directory.
  7. Doxygen
    • doxygen -g to create an empty configuration file.
  8. fc - fix command shell built-in command
    • By itself, you can edit your last command
    • With the -l option, you can get a list of commands. This can help you create a shell script off of your history.
  9. Z Shell (zsh) is actually worth a look, even if you love using Bash as much as I do.
    • It handles spaces in filenames (for use in for loops).
    • It can do floating-point arithmetic
  10. size_t
    • Can be printf'd with %zu
    • Led me to look up stdint.h and came accross intptr_t, which can hold a pointer.
  11.  GNU Autotools
    • I am planning to avoid these if possible. Hopefully CMake and Friends can get the job done.
  12. Python C Interface
    • Seems pretty simple to do the easy stuff. I would probably still recommend Python's ctypes module first, though.
  13. Type generic macros give C some basic ability to overload functions.

Wednesday, June 25, 2014

Perforce Edit and Revert in Emacs

I found this snippet of Elisp to be helpful for the most basic of Perforce operations:

(defun p4-edit ()
  "Open the file for edit"
  (let ((retval (call-process "p4" nil nil nil "edit" buffer-file-name)))
    (if (eql 0 retval)
    (setq buffer-read-only nil)
      (error "Perforce edit failed"))))

(defun p4-revert ()
  "Revert the file"
  (let ((retval (call-process "p4" nil nil nil "revert" buffer-file-name)))
    (if (eql 0 retval)
    (revert-buffer t t)
      (error "Perforce revert failed"))))

Sunday, April 27, 2014

Making Your Own InnoTab 3 Videos Using mencoder on Linux

Unfortunately, my daughter's InnoTab 2 got into a little accident and went to VTech heaven. My wife upgraded her to the InnoTab 3S. So far, so good, with the exception that her old ripped DVDs no longer work on the new device. The product manual is pretty clear about what kind of video format the InnoTab 3 will support, the problem was just finding an appropriate program for the encoding. Enter mencoder. Here is what I did to make compatible videos using mencoder (with libdvdcss2 installed) on Ubuntu 12.04 LTS:

mencoder \
-nosub \
-oac mp3lame \
-lameopts mode=2:cbr:br=96:vol=7 \
-ovc x264 \
-x264encopts profile=baseline:bitrate=600 \
-vf scale=480:272 \
-o movie.avi \

Friday, January 24, 2014

Using Cygwin and the MinGW Cross Compiler with SDL2

MinGW is currently the most popular way to use GCC on Windows. I recently found that there is a way of using MinGW from within Cygwin as a cross-compiler. I've recently been doing some OpenGL programming across both Linux and Windows, and using Cygwin has allowed me to keep my build system largely the same.
  1. I installed the following Cygwin 64 packages (I'm not sure if they are all necessary)
    1. mingw64-x86_64-binutils
    2. mingw64-x86_64-gcc
    3. mingw64-x86_64-gcc-core
    4. mingw64-x86_64-gcc-g++
    5. mingw64-x86_64-winpthreads
  2. Download the MinGW SDL2 development files.
  3. Extract the SDL2 development files.
  4. Copy source to dest (using SDL2-2.0.1 as the example)
    1. SDL2-2.0.1\x86_64-w64-mingw32\include\SDL2
    2. SDL2-2.0.1\x86_64-w64-mingw32\lib\libSDL2.a
    3. SDL2-2.0.1\x86_64-w64-mingw32\lib\libSDL2main.a
    4. SDL2-2.0.1\x86_64-w64-mingw32\bin\sdl2-config
  5. Edit C:\cygwin64\bin\sdl2-config
    1.  Change the "prefix" variable to /usr/x86_64-w64-mingw32/sys-root/mingw
    2. Remove "-XCClinker" from the linker line.
  6. Compile and link (statically)
    1.   x86_64-w64-mingw32-gcc.exe opengltest.c -o gltest.exe $(sdl2-config --cflags --static-libs) -lopengl32

Vim Indentation Based on File/Folder Name/Regex

I've been working between a couple of projects that have wildly different coding standards. Vim has a flexible way to change settings based on a file path regular expression. Here is an example line where I set my indentation to 3 if the file path matches the given regexes (forgive the sprawl across two visual lines):

autocmd BufNewFile,BufRead */projectfolder/*.cpp,*/projectfolder/*.h setlocal expandtab tabstop=3 shiftwidth=3

Wednesday, January 22, 2014

vegan edamame potato salad

I found this recipe on the back of some Bird's Eye shelled edamame a number of years ago. I can't find it anywhere online, so I thought I'd post it myself.

Preparation Time:  15 minutes
Cooking Time:  10 minutes
Total Time:  25 minutes
Serves:  6-8


  • 2 lbs small red skinned potatoes (quartered)
  • 1 package (16 oz) of Birds Eye Shelled Soybeans
  • 3 Tbsp olive oil
  • 2 Tbsp apple cider vinegar
  • 1 Tbsp Dijon mustard
  • 1 Tbsp brown sugar
  • 1 tsp salt
  • 1/2 tsp black pepper
  • 1 clove garlic, chopped (optional)
  • 1/2 red onion, thinly sliced.

Cook potatoes in large pot of salted water for 6-7 minutes or until
tender. Drain and allow to cool. Prepare soybeans per the packaged
directions. Set aside and keep chilled until needed. Mix the next 7
ingredients and whisk to blend. Combine the potatoes, edamame, and
onion with dressing. Mix well. Season with additional salt and pepper
to taste. Chill until ready to use.

Sunday, January 5, 2014

Clozure Common Lisp (CCL) on Raspberry Pi

This is a distillation of a few documents for my own use, including

This is how I was able to get Clozure Common Lisp (revision 15996) running on Raspbian (Wheezy version 2013-12-20 downloaded from
  1. sudo aptitude install build-essential m4 subversion
  2. svn co
  3. cd ccl/lisp-kernel/linuxarm
  4. make clean
  5. make

Friday, March 22, 2013

Virtual Box Guest Additions 4.2.10 in Latest Scientific Linux 6.3

This bug report helped me track down how to compile the OpenGL module. While the compiler error and fix for Scientific Linux (RHEL / CentOS) was different, than the one listed, the process was the same.

Additionally, this bug was not encountered with the initial 6.3, but only when I updated. My system information is as follows:

[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.32-358.2.1.el6.x86_64 #1 SMP Tue Mar 12 14:18:09 CDT 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# lsb_release -a
LSB Version:    :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:    Scientific
Description:    Scientific Linux release 6.3 (Carbon)
Release:    6.3
Codename:    Carbon

Thursday, March 14, 2013

Remapping CAPSLOCK to CTRL in Fedora 18

This guy figured out how to rebind CAPSLOCK to CTRL in Fedora 18.

Basically, running this command will change the setting:
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:nocaps']"

Saturday, March 9, 2013

Making Your Own InnoTab 2 Videos Using HandBrake on Linux

I was able to get my own videos working on the InnoTab 2 by following the InnoTab 2 product manual (you can download the PDF from the VTech website The only thing that tripped me up was that, according to the documentation, the InnoTab 2 expects a container type of AVI, but HandBrake only has MP4 and MKV containers. Using the MKV container type, but renaming the file extension to AVI seemed to do the trick. Here is the command line I used for a 16x9 movie that needed an audio gain increase:

HandBrakeCLI \
--format mkv \
--encoder x264 \
--x264-profile baseline \
--vb 600 \
--maxWidth 480 \
--maxHeight 272 \
--aencoder lame \
--ab 96 \
--gain 9 \
--input /dev/dvd \
--title 1 \
--output movie.avi

Monday, October 29, 2012

HandBrake for PSP 3000 with firmware 6.60

I had good success using the following command line (based off of the "iPhone & iPod Touch" preset):

HandBrakeCLI -e x264  -q 20.0 -a 1 -E faac -B 128 -6 dpl2 -R Auto -D 0.0 -f mp4 -X 480 -Y 272 -m -x cabac=0:ref=2:me=umh:bframes=0:weightp=0:subme=6:8x8dct=0:trellis=0 -i /dev/dvd -o ~/movie1.mp4 -t 12

Now you can create your own H264-encoded movies for the original PSP. Y-E-S!

Sunday, May 6, 2012

Logitech BT Mini-Receiver on Debian 6

I had a Logitech MX 5500 bluetooth mouse and keyboard that unfortunately broke. They came with a small USB dongle that can be used as a bluetooth receiver. It took me forever to figure out why the device wasn't registering as a bluetooth receiver on Debian Linux 6.0. Ultimately, the issue was with the udev rules.

In /lib/udev/rules.d/70-hid2hci.rules, I changed these lines:

KERNEL=="hidraw*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c70[4abc]|c71[34bc]", \
  RUN+="hid2hci --method=logitech-hid --devpath=%p"


KERNEL=="hiddev*", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c70[4abc]|c71[34bc]", \
  RUN+="hid2hci --method=logitech-hid --devpath=%p"

Friday, April 13, 2012

snd-intel-hda and speaker popping noise

My particular sound card, HDA NVidia with chip Conexant CX20549 uses the snd-hda-intel kernel module. Unfortunately, the default setting enables a power saving feature which causes the speakers to make a popping noise before and after playing sound. The fix in the past has been to edit /etc/modprobe.d/alsa-base.conf and add the line:

options snd-hda-intel power_save=0 power_save_controller=N

To verify that this is working, you should be able to reload the driver and cat the current value of the kernel module parameter (but I could not get this live reload working):

alsa force-reload
cat /sys/module/snd_hda_intel/parameters/power_save

I rebooted and sound was working. Then, I took my laptop on battery power and I experienced the popping again. Sure enough, the value of power_save had been reset. After searching Google with the right terms, I came across a post which pointed me to a script that was being run by the power management software. The script was resetting the value of power_save, making it appear as if alsa-base.conf were being ignored or that putting the computer to sleep were resetting my options. To patch the script, I set the value of a variable to false. Specifically, I edited /usr/lib/pm/power.d/intel-audio-powersave and set the line starting with "INTEL_AUDIO_POWERSAVE" to:


I hope this helps some poor soul with popping speakers. For the record, I'm running on an HP dv6636nr dv6000 series laptop with Ubuntu 11.10 32-bit.

Wednesday, September 14, 2011

python email dates

When using Python to send email, you may find that you need to set the Date: field. This task is made trivial with the standard module email.utils. The following will likely be what you want:


Tuesday, June 28, 2011

setting a Windows 7 service as Automatic (Delayed Start) from the command line

I wanted to set my condor service to start automatically, but (hopefully) after network was available to get around the problem discussed on the Condor Users mailing list.

Here's the command:
sc config condor start= delayed-auto

Monday, May 23, 2011

clozure common lisp windows 7 64 bit dlls for opengl


I am learning OpenGL and Common Lisp at the same time...

If you need 64-bit DLLs to use lispbuilder-sdl or cl-opengl with Clozure Common Lisp on Windows 7 64-bit version, I compiled some from source using Microsoft Visual Studio 2008. I certainly can't guarantee that they will work for you, but hopefully they do.

Tuesday, December 7, 2010

Script for Cronjob to Check for a Full Disk

I found a nice script on the Ubuntu forums (I think) for checking if a Linux system had a full disk and then sending an email if that was the case. I adapted it a little bit to provide more information in the case that /home is full. I'm posting it here in case anyone were to find it useful.

#set -x

df -H | awk '!/^Filesystem|tmpfs|cdrom|AFS/ { gsub(/\%/,"",$5); print $5,$1,$6}' | while read line
    eval $(echo "$line" | awk '{print "PERCENT_FULL="$1";DEVICE="$2";MOUNT_POINT="$3}')
        echo -e "On $(hostname), the mount point $MOUNT_POINT is $PERCENT_FULL% full.\n"
        echo "df --human-readable shows:"
        df --human-readable $DEVICE
        if [ "$MOUNT_POINT" == "/home" ]; then
            du --one-file-system --summarize --human-readable ${MOUNT_POINT}/* > $OUTPUT_FILE
            echo -e "\nHere is the disk usage by directory listing, sorted from greatest to least."
            for directory in `du --one-file-system --summarize ${MOUNT_POINT}/*  | sort --reverse --numeric-sort --key=1 | awk '{print $2}'`
                grep "$directory" --word-regexp $OUTPUT_FILE
        ) | mailx -s "ALERT: $MOUNT_POINT on $(hostname) is $PERCENT_FULL% full" $TO_ADDR

Friday, November 12, 2010

Python and Condor

I wanted to see if I could run Python 3.x under Condor as a vanilla job. It seems to work fine. Here's what I did:

1. Built Python and tarred it up:

export PATH=/usr/bin:/usr/sbin:/bin:/sbin
export INSTALL_DIR=/scratch/mick/src/python-3.1.2-x86_64-rhel5
mkdir -p $INSTALL_DIR
tar xjf Python-3.1.2.tar.bz2
cd Python-3.1.2
./configure --prefix=$INSTALL_DIR
make install
cd $INSTALL_DIR/lib/python3.1/lib-dynload
ldd *.so | \
grep '/usr/' | \
gawk '{print $3}' | \
sort -u | \
while read n; do cp $n $INSTALL_DIR/lib; done;
cd `dirname $INSTALL_DIR`
tar czf python-3.1.2-x86_64-rhel5.tar.gz python-3.1.2-x86_64-rhel5

2. Created a wrapper to extract the tarball and run python. I called my wrapper 'python3'



/bin/tar xzf ./$VERSION.tar.gz
exec ./$VERSION/bin/python3 "$@"

3. Submit your job.

universe                = vanilla
executable              = python3
arguments               =
should_transfer_files   = yes
transfer_input_files =, python-3.1.2-x86_64-rhel5.tar.gz
when_to_transfer_output = on_exit
output                  = condor.out.$(CLUSTER).$(PROCESS)
log                     = condor.log.$(CLUSTER).$(PROCESS)
error                   = condor.err.$(CLUSTER).$(PROCESS)

Friday, November 5, 2010

Oh man.

I've wanted to be able to view man page source files, but I had trouble looking up how to do that (the search terms are kind of generic). So, if you'd like to view and/or format raw man page source files, the following is probably sufficient:

nroff -man manpage_source_file.1 | less

Sunday, July 18, 2010

Logitech MX 5500 on Linux in USB mode

So, I didn't want to use the Bluetooth mini receiver, and wanted to use my wireless keyboard and mouse in the USB mode (no OS bluetooth support needed; everything is done in hardware). All I had to do was comment out the lines related to Logitech devices in:

After that, I was able to use mx5000-tool to change a few of the LCD screen views. Not to mention, I can remap CAPS LOCK to CTRL and it won't beep each time I press it. Whatever.

Friday, July 9, 2010

manipulating pdfs with pdftk

I've been downloading some PDF articles that I wanted joined together for duplex printing purposes. While Ghostscript can join PDFs quite well, pdftk is a great tool for removing pages that I didn't want to keep (before joining). has a good article to get started.

I specifically wanted to remove the last page of each of my documents. To remove the last page, I needed to know how long the document was:

$ pdftk article.pdf dump_data output | grep NumberOfPages
NumberOfPages: 132

Then I can use the "cat" function of pdftk to create a new PDF minus the last page. Then, I can merge all the documents. I should probably write a bash script for this.

Tuesday, June 22, 2010

fix for cups socket printing in Debian GNU/Linux 6.0 testing

I couldn't print to a Dell M5200 printer and found that I was getting a socket error. I was able to telnet to the printer, so it wasn't my network connection... It turns out it was a permissions problem. This bug thread for Ubuntu seems to have more.

Thursday, June 17, 2010

slime and sbcl with Debian 6.0 testing

I had some trouble getting slime to work with Debian 6.0 testing using sbcl. This page had the answers. It might not be ideal, but it's working for right now.

Thursday, June 10, 2010

Adding a screensaver to Ubuntu 10.04

I wanted to add a simple screensaver that had a floating SVG of the Condor project's logo. You can download the SVG file here.

  1. sudo cp condor_logo.svg /usr/share/pixmaps
  2. cd  /usr/share/applications/screensavers
  3. sudo cp footlogo-floaters.desktop condor-floaters.desktop

  4. sudo vim condor-floaters.desktop
    [Desktop Entry]
    Name=Floating Condor Logos
    Comment=Bubbles the Condor logo around the screen
    Exec=/usr/lib/gnome-screensaver/gnome-screensaver/floaters /usr/share/pixmaps/condor_logo.svg
  5. sudo /usr/share/gnome-menus/update-gnome-menus-cache /usr/share/applications > /tmp/desktop.en_US.utf8.cache
  6. diff /usr/share/applications/desktop.en_US.utf8.cache /tmp/desktop.en_US.utf8.cache
  7. Make sure the diff looks like what you expect
  8. sudo cp /tmp/desktop.en_US.utf8.cache /usr/share/applications/desktop.en_US.utf8.cache

Thursday, April 15, 2010

improving blackboard backups with condor

I just saw a fantastic presentation on how to speed up slow Blackboard backups using Condor. I don't use the software personally, but I know it is big at a number of colleges. You can see the presentation here.

Thursday, April 8, 2010

fvwm keybindings using the Windows key

Had I known that the Windows key is simply modifier 4 under FVWM 2, I would have been a lot happier with it. Here is an example:

Key  Q        A  4 RaiseLower

Thursday, March 18, 2010

Strawberry Perl

I just hate Microsoft Windows. But, that's where the man pays me to work. When I had to install Perl, I disregarded ActivePerl in favor of the less corporate Strawberry Perl. It works delightfully!

I used it to convert Hot 108 Jamz WinAmp PLS playlist to an M3U playlist for Windows Media Player (don't ask me why... I forget). I used the scripts from the Linux Lighting Group found here.

Wednesday, March 3, 2010

Fade To Black

I used ImageMagick to create a TGA sequence that faded from black to a logo, and then from the logo back to black. This is the gist of my Python script:

 for i in range(0, 101, 2):
  os.system('composite -dissolve %d logo.tga black.tga %03d.tga' % (i,  (i / 2)))

Thursday, November 26, 2009

Fedora Core 12 on PS3

I installed Fedora Core 12 on my PS3 today.

It started out as a disaster and got better as time went on. If you are trying the same version, you should definitely read:

Friday, October 2, 2009

Turn Off Nautilus in Yellow Dog Linux 6.2

I wanted to turn off Nautilus in Yellow Dog Linux's default E17 session. A quick Google search revealed that the answer was the following command:

gconftool-2 -s -t bool /apps/nautilus/preferences/show_desktop false

Monday, September 14, 2009

Euclidean Algorithm in C


My number theory professor asked the class to program the Euclidean Algorithm in a language of our choice. I did mine in C.

I've attached my copy.

Sunday, September 13, 2009

Yellow Dog Linux release 6.2 (Pyxis)

My computer, my partner in crime for six years, died. The motherboard went bad. So I used my wife's old computer, and the hard drive went in that one. Then I got a used one from a friend. That one broke, too (I suspect it's the motherboard, but who knows?).

All I have left is my trustworthy Playstation 3.

I've messed around with Linux on the PS3 before, but I've never had to use it as my only desktop. This time around, I had to make it work (I'm out of a job right now, so buying something else is not an option).

I installed Yellow Dog Linux 6.2. It definitely feels more responsive than 6.1 (the swap performance improvements are certainly noticeable). In addition, they have now added many more packages to the yellowdog-extras repo.

After a fairly quick install, I installed all of my favorites from the YUM repositories, namely Fluxbox, LaTeX, and Emacs. The base install had already chosen Firefox and Pidgin, so I was ready to roll. I've been relying on Google Docs for some time as my office suite, and it continues to work well within Firefox. Audio worked out of the box, so no issue there. I do admit to being a little old and crotchety in the audio player department, so I compiled XMMS 1.x from source and installed it in my home directory.

The only thing missing? Printing. I had never really used CUPS before, but now I'm glad that I did. It was a total snap! My particular wireless printer didn't have a driver with the base CUPS install. I pointed Firefox to the CUPS configuration server at http://localhost:631 and began to add a printer. It was no big deal to download a PPD file from the OpenPrinting database. Minutes later and I was printing out my documents.

I sincerely LOVE Linux! It even works for poor people.

Monday, July 20, 2009

Emacs Keybindings in Visual Studio

I've been using the Emacs keybindings in Visual Studio for a little while. There was just one thing that drove me crazy. It would not autoindent into the current line, nor would it indent when you hit TAB. You actually had to have source code on the line before TAB would do a smart indent.

Someone from Microsoft had originally written some Visual Studio macros to address this. You could rebind TAB to just do a plain old tab insert. Of course the source code URL I found was no longer valid... So I contacted the engineer at Microsoft. He got back to me and told me that he no longer had the source, but that it shouldn't be too hard to write my own.

It took me about 15 or 20 minutes to get it correct. You have to use the Macros IDE to add a module under "MyMacros". I called mine "EditorMacros". You should unbind "Edit.InsertTab" and rebind it to the sub routine below ("Macros.MyMacros.EditorMacros.EmacsInsertTab.") It looks like this

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module EditorMacros

'' Please insert a TAB!
Sub EmacsInsertTab()
Dim editPoint As EnvDTE.EditPoint
Dim selection As EnvDTE.TextSelection
Dim startPoint As EnvDTE.EditPoint
Dim currentPoint As EnvDTE.EditPoint
Dim endPoint As TextPoint

selection = DTE.ActiveDocument.Selection
If (selection.IsEmpty()) Then
editPoint = selection.ActivePoint.CreateEditPoint()

'' 0x09 is an ASCII horizontal tab
startPoint = selection.TopPoint.CreateEditPoint()
endPoint = selection.BottomPoint
currentPoint = startPoint
Do While (True)
Dim line As Integer

line = currentPoint.Line
If (line = endPoint.Line) Then
If Not (currentPoint.AtEndOfLine()) Then
End If
Exit Do
End If
End If
End Sub

End Module
That seems to work just fine. But every time I hit TAB, a pop-up balloon would flash from the task tray. After seeing that thing for 10 or so times, I lost my mind. It was so brief I couldn't even read what it said. What to do? Why not add a sleep function into my macro? Here's the snippet:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub EmacsInsertTab()
'' Somewhere in the body...
End Sub

The pop-up said that a macro was running and that I could kill it from the pop-up. Thanks! That's so useful! My macro takes a fraction of a second, of course I'd like the opportunity to stop it. Anyway, it has the option to dismiss it forever.

I took the sleep out and went on my merry way.

Thursday, May 14, 2009

toggle word wrap add-on in Thunderbird

Nine times out of ten, I want Thunderbird to wrap my lines at 72 characters. However, there are times when I'm pasting code or other pre-formatted text that I need word wrapping off. Someone must have had the same problem and made an add-on that easily disables this from the Options menu in the composer.

Saturday, April 18, 2009

fluxbox hotkeys, keyboard shortcuts, keybindings, whatever

I've been away from Fluxbox for a long time. It took me FOREVER to figure out how to even set my background. I headed on over to and started to get a grasp on a few of the new features. The biggest one that they have has to be a great keyboard shortcut system. Just edit ~/.fluxbox/keys and you're on your way. I've added the following to mine:
# use the arrow keys to change workspaces
Control Mod1 Left :PrevWorkspace
Control Mod1 Right :NextWorkspace

# volume settings
Control Mod4 Up :Exec mixer pcm +1 ogain +2
Control Mod4 Down :Exec mixer pcm -1 ogain -2

And before I forget, you can set your background with an override in ~/.fluxbox/overlay like this:

background.pixmap: /home/mick/private/pictures/gta3_greencar.jpg

Monday, March 23, 2009

freebsd moused

In the 6 or so years that I've used FreeBSD, I've never successfully configured the mouse daemon (moused). It allows the user to have a mouse in both the virtual consoles and X windows, using the same device. I have a pretty standard Logitech USB mouse. It shows up as /dev/ums0 in FreeBSD 7.1. Turning on moused is as simple as adding the following lines to /etc/rc.conf


Now I've got a fully functional mouse with looks that kill.

Friday, February 20, 2009

xdm hold the debian, please

I switched from GDM to XDM. You have no idea how infuriating that extra second of waiting can be for someone who works on computers all day long. Anyway, the Ubuntu package of XDM appears to be directly from Debian. They replaced the standard logo with a Debian swirl. To change this back to how it was, edit /etc/X11/xdm/Xresources.

xlogin*logoFileName: /usr/share/X11/xdm/pixmaps/debian.xpm

xlogin*logoFileName: /usr/share/X11/xdm/pixmaps/xorg.xpm

This also points to you being able to change that pixmap to whatever suits your fancy. May I recommend a sweet photo of Max Headroom or HAL 9000?

God is love,
Rev Beav

Wednesday, February 18, 2009

xmessage and the simple things in life

I have a slow computer. I bought it before I could grow a beard or even any back hair. Full on GNOME is usually a little too heavy, so I run everything from FVWM to Fluxbox to whatever.

I thought it would be nice to shutdown with a menu command.

The program xmessage will allow you to setup multiple buttons, each with a different number. That number will be the return code for the program. Bash (bless its little heart) will allow you to query the return code in the variable "$!". They seem like a natural fit!

I did a little visudo so that my group could call shutdown without entering a password.

%admin ALL=NOPASSWD: /sbin/shutdown

Here's the contents of my shutdown script:


xmessage -buttons "Yeah boy!":0,"Quit rushin' me...":1 "Shut this bitch down?"

if [ $? == 0 ]; then
sudo shutdown -h now

Wednesday, January 21, 2009

using html instead of plain text in mozilla thunderbird

I generally use plain text mode in Mozilla Thunderbird for all of my email. Sometimes I need to send off an HTML mail, though. It turns out that holding shift and then clicking "Write" or "Reply" is all it takes to switch to HTML mode for just that one email. I read about it here:

Essentially, hold down shift when you click "Write" or "Reply". That's that.

Thursday, September 11, 2008

installing pylint on win32

Installing pylint on win32 with Python 2.5.2 is fairly straightforward:

1. Download logilab-common (under common), logilab-astng (under astng), and pylint from
2. Extract all sources.
3. Inside each base directory, run: C:\Python25\python.exe bdist_wininst
4. You will find an exe to run in in each directory's dist folder.
5. Install common, then astng, then pylint.
6. Run pylint.bat from C:\Python25\Scripts\pylint.bat

Wednesday, September 3, 2008

My Symmetric Processing Elements

I am trying to turn into a useful individual by learning more about programming for the Cell Broadband Engine. I installed openSUSE Linux 11.0 on my PS3 a few months ago and just last night was able to get some code running.

I followed the following guide:

Everthing compiled okay, but I kept getting the error "spu_create(): Function not implemented". The fix was to mount the spufs. Contrary to the spufs(7) man page, this was actually done by adding the following to /etc/fstab

none    /spu    spufs   default    0 0

I will still probably need to add the spufs kernel module to /etc/modules so that it is always loaded upon boot.

Wednesday, June 4, 2008

Preparing a Video for the PS3

Last night, I was able to convert a .MOV to an XVID-encoded .AVI using mencoder. This was then playable using the Playstatoin 3 video playback off of a USB memory stick.

Here is the video manual:

I ran the following command:

mencoder -oac mp3lame -lameopts cbr=128 -ovc xvid -xvidencopts bitrate=1200 -o output_filename.avi

This says that you want to have MP3 audio encoded at 128 kbps and XVID encoded video at 1200 kbps, which seem to be reasonable quality settings. I also ripped a DVD using the following command:

mencoder -oac mp3lame -lameopts cbr=128 -ovc xvid -xvidencopts bitrate=1200 -o output_filename.avi dvd://0

You may need to increment the number following the dvd:// until it is correct, though 0 is often the right one.
You can download mencoder along with MPlayer from:

Wednesday, May 28, 2008

FreeBSD boot splash

Tonight I was able to set up a FreeBSD boot splash screen. It was an enjoyable experience.

1. I edited /boot/loader.conf and added the following:


2. I edited the wallpaper found at to make it 256 colors and 1024x768. You may download the modified version here.

3. I moved the wallpaper to /boot/kernel/splash.bmp

4. Rebooted

5. Enjoyed the splash screen. The only issue was that it didn't go away when the boot was finished until I pressed a key. This isn't an issue for me personally, since I use XDM, which cleared it away.

Thursday, April 24, 2008

Metal Gear Solid 2: Substance PC Hex Edit

Without looking at the code, it's impossible to tell why MGS2 has so many issues on the PC using an NVIDIA GeForce graphics card. Regardless, people smarter than me have spent some time figuring out how to edit the binary to replace what appears to be search strings looking for ATI cards, thus allowing NVIDIA GeForce cards to run at full settings. I haven't gotten a chance to try thise myself, yet, but I certainly will soon.

Explanation 1 taken from here:
First download and install patch v2.0 from here:

Then you need an hex editor like frhed or whatever.

Find the files mgs2.exe and mgs2_sse.exe in the game's directory and make a backup copy of them in case you mess it up.

Now open the file mgs2.exe with the hex editor and go to edit->find and use the word "geforce" as a search term. Now the word "GeForce" should be highlighted and right next to it to the left side is the word "RADEON". These are the 2 entries you have to edit.

You have to replace the "GeForce" with whatever you like as long as the letter count remains the same. I just overwrote it with "removed".

Then the word "RADEON" to the left, this you have to overwrite with "GeForc". Notice the capital "G" and "F" and also missing "e" at the end, it should look exactly like that.

Now save and do the same steps with the mgs2_sse.exe file.

And just in case:


This should help to fix the problems with NVIDIA cards.

Explanation 2 taken from here:
Don't think from your message that you will have tried this fix, however you have a GeForce card anyway so do this, (thanks to the original poster, can't remember where I saw it now) -

1. Install MGS2.
2. Install the ATI 2.0 patch.
3. Find the files mgs2.exe and mgs2_sse.exe within the directory where the game was installed.
4. Backup a copy of each of these original files!
5. Open mgs2.exe with a hex editor... Frhed is a nice free utility that will suffice for this job:
6. Look for the string RADEON, which starts at the following offset: 0x5f6e44.
7. Replace RADEON with ALL-IN. Don’t add or subtract anything else
8. Save the file.
9. Repeat steps 5-8 for mgs2_sse.exe. Note: this might not be necessary; on my system, Metal Gear seems to only use mgs2.exe… also, the hex offset will be different, but it’s easy to find by analogy.

Right, now you will need to follow the instructions but do a couple of things differently. At point 6&7 instead of replacing "RADEON" with "ALL-IN", replace it with "GeForc". Note the capital G and F and no e on the end. Near (right next) to where it now says GeForc, there will be the string "GeForce" (this starts at 0x5f6e4c in mgs2.exe and 0x5fd83c in mgs2_sse.exe). Replace "GeForce" with anything else as long as it has the same number of letters. The game will now use the Radeon graphics path on a geforce card and looks a hell of a lot better (tested on a GF 6800).

Monday, March 24, 2008

GNOME Terminal colors

When using gnome-terminal, I kept running into the issue of having an obnoxious gray background when using vim in the terminal. After doing some digging, it seems I need to set my gnome-terminal palette.

This is accomplished by:
  1. Edit ⇒ Current Profile...
  2. Choose the Colors tab
  3. Under the Palette section, change Built in schemes to XTerm.
  4. Stop crying.

Saturday, March 22, 2008

openSUSE 10.3

For the longest time, I tried to use FreeBSD 6.x. I found it remarkably stable and reasonably fast. Even though it has a decent binary package management system, there are a number of packages that I built from source for customization reasons. Like Gentoo Linux, the compile times quickly got out of hand. If you are using FreeBSD, make sure to look into portupgrade and its options for configuring software wholesale before an update of all of your installed ports and packages.

Compile times aside, not having an Adobe Flash plug-in (Gnash would crash the X server) is what lead me back to Linux. I've been a big fan of Debian for the longest time, but each time I come back to it, they make it harder and harder for me. The deal with Iceweasel and Icedove is enough to make me puke, as well as how long it takes to get new software.

It seems like all roads lead to Ubuntu. I gave it a shot, but my heart just wasn't in it. I tried Fedora, but that didn't trip my trigger either.

Enter the most reasonable distribution (for me) that I've tried: openSUSE

As with all GNU/Linux distributions, there are a significant amount of things that are exactly the same across all of them, especially in the way of userland. Here are the things that are different about openSUSE.

  1. Top-notch installer. I have to say that the installation process was fantastic from beginning to end. I chose to do a network install and no issues.
  2. Package management at its finest. I've used a few different package managers out there, including FreeBSD/OpenBSD ports & pkg_*, APT, YUM, and Gentoo Linux portage. So far, I think I like SUSE's YaST the most. It has a text mode, a GUI mode, and (here's where it is terribly convenient) the ability to automatically add software and software repositories by clicking on a link to a YMP (YaST MetaPackage). This is how I effortlessly added binary NVIDIA drivers.
  3. Great artwork. While not a technical feature, if I have to sit at a desk all day long, every day, it's easier if it's pretty. No shit brown and burnt orange here. Just a calming green with a number of chameleon logos.
  4. Great documentation. While many people point to Ubuntu as having the best documentation, what they may actually mean is that Ubuntu has one of the best user communities, who answer question after question in the forums. I actually feel like Ubuntu has slightly lacking documentation. With openSUSE being a test harness for SUSE Linux Enterprise Desktop, the documentation is also of enterprise quality. The wiki (which is quite beautifully laid out) is also great.
Ultimately everyone should use what works for them, or what their boss says to use, but if given the opportunity, I'd say take a peek at openSUSE. It's free, attractive, easy, and doesn't suffer from a lot of the obnoxious parts of other distributions (like in-your-face methodologies, unprofessional web sites, ridiculous mascots, bad or impossible to pronounce names, etc.).

Thursday, March 6, 2008

PostgreSQL SERIAL Saved My Life

I needed to prototype a small application that needed a database back-end. I usually just use the Python ODBC bindings (pyodbc), so as long as I had an ODBC driver installed, it didn't really matter which database management system I used.

Being sound of mind, I chose PostgreSQL and began sketching out my simple schema. I ran into a snag because I didn't know how to simulate the ever increasing identifier integer, like MySQL's auto_increment or Microsoft SQL Server's IDENTITY. Enter the pseudo-type SERIAL. It works exactly the same, but on a DBMS you can bring home to your parents.

Check it out here:

Wednesday, March 5, 2008

Interactive Python and It's Good Friend _

I had no idea, but when using the interactive Python interpreter, the variable '_' (without quotes, of course) stores the last thing that was successfully printed to the screen.

>>>> 2 ** 8
>>>> _
>>>> _ ** 8
>>>> 'Oh yeah'
'Oh yeah'
>>> _.split()
['Oh', 'yeah']

You get the idea. How convenient! I should read the docs more often.

Wednesday, February 20, 2008 2.3.1 and FreeBSD

So, it turns out that 2.3.1 on FreeBSD was behaving oddly (not opening documents) due to a missing environment variable. This seems like a bug to me that will be fixed sooner or later. Regardless, normal functionality may be returned by setting the following:


freebsd-openoffice mailing list archive at

Friday, February 8, 2008

My Destroyed Faith in OpenOffice Presentations

So, I'm working on a presentation for work. I can't bring myself to use PowerPoint, since Microsoft has done such a good job of ruining my software self-esteem. I think to myself, "Well, why not Impress? It uses the OpenDocument Format, which is damn fine computing karma." So, I made my first draft in OOo 2.3.1 on Win32. Then, I attempt to continue working on the same ODP file on OOo 2.3.1 on FreeBSD. It seemingly hangs. No progress after minutes of processing. Fucking great. Running it from an xterm gives me these messages (no idea if they're related):

(process:1152): GLib-GObject-CRITICAL **: gtype.c:2242: initialization assertion failed, use IA__g_type_init() prior to this function

(process:1152): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(process:1152): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
That doesn't look good. I'm going to let it keep running for a while to see if things improve, but the outlook is poor. In the meantime, I've decided that the best alternative to multi-platform document creation and editing is Google Docs. It's not perfect, but at least you can save your files as PDF, which is what I use for read-only document exchange anyway.

Since I don't have a Microsoft Windows computer at my disposal, I have to figure out someway to get at least the text portion out of my ODP. This is my half-baked solution for extracting the text:
  1. $ mkdir presentation
  2. $ cd presentation
  3. $ cp ~/path_to_presentation/my_presentation.odp .
  4. $ unzip my_presentation.odp
  5. $ > my_presentation.txt

#!/usr/bin/env python2.5
# -- extract the text parts from an ODP's content.xml
import re
for line in open('content.xml', 'r')
for text_part in re.findall(r'<text:p.*?>(.*?)</text.*?>', line):
print text_part.replace('<text:line-break/>', '')

Wednesday, February 6, 2008

Ecplise 3.3 Exploded My Face

So, Eclipse + PyDev seems to be the premier way to visually debug python apps. The first time you debug your application, you have to choose the debug configuration you want to use, Python or Jython or some others. Anyway, after you make your selection once, you can hit "F11" to debug your last launched. Or at least that's how it used to work.

In Eclipse 3.3, you have to check a special configuration option to get the old behavior. That way you don't have to needlessly click the same debugging configuration each time. The PyDev documentation clued me in to this.

Note: This behavior changed in Eclipse 3.3 -- but it's generally recommended to restore it in the preferences at: window > preferences > Run/Debug > Launching and set the Launch Operation to Always launch the previously launched application. This tutorial will always consider this as the default option.
After that, F11 rocks your world.

Tuesday, February 5, 2008

GVIM ♥ Python

When I'm not using UNIX, I'm not. To try and make things a little more tolerable, I use GVIM as much as possible. Unfortunately, the win32 GVIM release expects Python 2.4 if you want to use the amazing omnicomplete Python functions. I hit the wall today and broke down in tears, knowing that I had Python 2.5.1, but a GVIM that didn't use that.

The solution was to compile a GVIM executable myself! It turns out that it is fairly easy. I also assume that Vim is already installed.
  1. Download the source archives.
  2. Extract
  3. CD vim71\src
  4. "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"
  5. nmake -f Make_mvc.mak FEATURES=HUGE GUI=yes OLE=yes MBYTE=yes IME=yes GIME=yes PYTHON=C:\Python25 DYNAMIC_PYTHON=yes PYTHON_VER=25 CSCOPE=yes
  6. Make sure the regular Vim 7.1 is installed. I used the installer located at
  7. COPY /Y gvim.exe "C:\Program Files\Vim\vim71\gvim.exe"
  8. COPY /Y GvimExt\gvimext.dll "C:\Program Files\Vim\vim71\gvimext.dll"
  9. Turn up your Ashlee Simpson CD
That seems to be it. I didn't add support for TCL, Perl, or XPMs, but you're a smart kid. You can figure it out.

I Threw My MBR Off The Deck

When installing FreeBSD, it gives you the option to install the FreeBSD boot manager or a standard MBR. Since I only have one operating system on my hard drive, a standard MBR will boot right into FreeBSD.

Well, instead of doing the right thing, I did the wrong thing and installed the FreeBSD boot manager, also known as boot0. Luckily, UNIX is amazing and gives you the option to fix things. A quick look at boot0cfg(8) (which means type 'man 8 boot0cfg'), and you can see that the fix is:
  • fdisk -B ad0

The -B option to fdisk means, "Reinitialize the boot code contained in sector 0 of the disk." In FreeBSD, your devices are referred to by the kernel module/driver they use. "ad" is the "generic ATA/ATAPI disk controller driver" and 0 is the number of the first ATA/ATAPI disk (zero-indexed, of course). You might have a different disk. Adjust that last argument as necessary.

Friday, February 1, 2008

X Windows and Unicode

X Windows does seem to support Unicode input. For learning a foreign language, often times an accent mark is put over a letter to indicate syllable stress (lookup diacritical marks if you're interested in more). Anyway, to put an accent over a vowel, placing U+301 after the vowel in question will place the accent mark.

  • In regular X Windows
    • I've bound it to an unused key. First, add 0x100000 to the Unicode code point in question, then bind that value to a keycode.
    • xmodmap -e 'keycode 117 = 0x1000301'
  • In GNOME
    • Hold CTRL + SHIFT, then press 3, then 0, then 1, then release
  • In gVim
    • CTRL + V, u, 0, 3, 0, 1