Archive for the ‘Programming’ Category.

Multi-Threaded Programming with QtConcurrent

I’m really looking forward to QtConcurrent which will be in Qt 4.4; so I downloaded a Qt snapshot to try it out.

You can download all of the example code I wrote here, Qt Concurrent Examples
Continue reading ‘Multi-Threaded Programming with QtConcurrent’ »

QMake Major Mode for Emacs (qt-pro.el)

I finally got around to writing a major mode for Qt .pro and .pri files. It doesn’t provide any indenting features; only font locking.

Just load it up and add the following to your .emacs

(requireqt-pro)
(add-to-list ‘auto-mode-alist ‘(“\\.pr[io]$” . qt-pro-mode))

Get it here qt-pro.el

[Digg] [Reddit] [DZone]

Covariant Return Types

I ran across something weird the other day. I had assumed that the return type of an overriding function must be identical to the function that it is overriding. The C++ Standard allows one specific exception to this rule that could possibly come in handy to save some unnecessary casting.
Continue reading ‘Covariant Return Types’ »

Falling Snow…

Quick falling snow hack with Python and Pygame. Snow eventually accumulates and fills the screen…

Falling Snow Screenshot

Falling Snow Source

[Digg] [Reddit] [DZone]

SLIME Problem with SBCL

When starting up SLIME (M-x slime) I’m getting a hangup error:


;; Swank started at port: 36773.
36773
* 
Process inferior-lisp hangup

From searching, this appears to be a problem with Emacs and my version of the Linux Kernel (2.6.8). The workaround is apparently to set the inferior lisp to “nohup sbcl” which prevents SBCL from receiving the hangup signal. Unfortunately it also redirects STDOUT/STDIN which seems to cause a problem with the SLIME from CVS.

The solution that I’ve found is to start swank (the Lisp portion of SLIME) manually in SBCL.


; Load swank
(load "/path/to/swank-loader.lisp")
 
; Start the swank server
(swank:create-server)

Then in Emacs start SLIME with M-x slime-connect, the defaults of Host: 127.0.0.1 and Port: 4005 should be fine.

SLIME Screenshot

[Digg] [Reddit] [DZone]

Export Thunderbird Addressbook to Palm

A script to put a Thunderbird Addressbook on a Palm

Run Mozilla Thunderbird, open the addressbook, click Tools->Export and export it to a CSV file, say mozilla.csv

Use it like this:


./ThunderBird2Palm.pl < mozilla.csv > palm.csv
pilot-addresses -p /dev/pilot -r palm.csv
pilot-dedupe -p /dev/pilot -r AddressDB

Requires Perl, Text::CSV, new version of pilot-link

ThunderBird2Palm.pl

[Digg] [Reddit] [DZone]

Plagiarism Detection

Test a document (MS Word or TXT) at http://www.tolchz.net/plag/

[Digg] [Reddit] [DZone]

PopBg

This Perl script creates a background out of images that it finds on the internet through searching for random words out of the dictionary at images.google.com . It uses PerlMagick for the image functions and currently uses xloadimg to display it on the background.

Download
Edit the first few lines
Place in crontab
Enjoy

randomimage.pl

[Digg] [Reddit] [DZone]

SDL Lights Out

5×5 Grid of randomly lit and unlit boxes, clicking a box flips the boxes in a cross shape
around the box clicked
Uses SDL_Image and SDL_TTF
Press ~ to get to Console

lights.tgz

[Digg] [Reddit] [DZone]

SDL Bouncing Ball

A Simple SDL Demo that uses Hardware Acceleration and Double Buffering to draw
three Sphere images on the screen and bounce them around a bit.

It uses SDL_Image for loading the PNG file.

Copy and paste the source code to a file and compile it like this:

gcc -Wall -ansi -pedantic `sdl-config –cflags` -c bounce.c
gcc -Wall main.o -o main -lSDL_image -L/usr/X11R6/lib -L/usr/lib -lSDL -lpthread

Bounce.c

[Digg] [Reddit] [DZone]