Email: [freyguy77@gmail.com]
Office: [302.831.6034]
Dr. Jeffrey T. Frey

 Frey:/ Programming Research Recipes Literature 
 Frey:/programming/ Clustering Dropbox2 MacNetworkInfo NetworkingAdditions UDCarillonServices ncutil TubeGen stigma 
Programming News
The programming area of my site has now been through a complete retrofit (which isn't surprising, considering I've had to redo the entire web site). In this area you'll find all the information available on my various programming efforts; some projects have entire sub-areas devoted to them, some are mentioned merely on this page itself.

Some of the projects are available to download directly from the web site, but others are only available via my password-protected CVS server. In those cases, email me with a request for an account and password if you're interested in obtaining source code.
Linux Clustering Items
I've written some interesting software for the Linux clusters that I maintain. Some of it is made available on the Clustering sub-area, including:
  • gqueue: A utility that writes GridEngine queue submission scripts for you. The utility was first written for Gaussian input files -- the input file was scanned for processor counts, etc, and the appropriate parallel environment was selected based on this count. Since then, the utility has evolved to use external scripts/executables for the scanning and merging of input file content. The main reason for gqueue is now to simplify end-user interaction with GridEngine -- making it easier for them to transition to using a queue system.
  • autosync: Written to provide me with a configurable "backup utility" that uses rsync to mirror a set of directories to another directory/disk. As stated on the autosync page: "An automated, multi-path backup tool that uses rsync for transport."
Numerical Array Visualization in Cocoa
So you're a scientific programmer and you want to display your atomic C numerical arrays in a Cocoa app? Well, you could attempt to drop the entire array into an NSArray of NSNumber instances, but that's duplicating data and could take a while! What alternatives are there?

Before Cocoa bindings were around to simplify the display of NSArray data a programmer had to implement specific methods that would allow a class to act as a data source for an NSTableView. To that end, the NumericalArrayDS class is a generalized numerical-array data source for NSTableView instances. It handles reconfiguring the NSTableView to have the appropriate number of columns for your data and moves data from the array to the NSTableView -- as well as taking input values from the user and moving them to the array if the NSTableView allows editing! Not only that, but on Mac OS X 10.4 and newer the class even displays tooltips above each cell, indicating over which row and column the mouse is hovering.

The interface between the NumericalArrayDS class and the actual array is modeled by a formal protocol, so you can easily extend your existing numerical classes to work with NumericalArrayDS for tabular display. Implement the NumericalArrayAccess protocol and you're done! There are two wrapper classes included that will allow you to represent any integer or floating-point array, row- or column-major, full or lower- or upper-triangular.

Given a 5 x 5 lower-triangular array of float's in column-major storage orientation, the following code snippet would get an NSTableView to display the data (font size of 12, maximum column width of 100):
void setupTable( NSTableView* theTableView, float* theValues ) { NumericalTriangularArray* theArray = [[NumericalTriangularArray alloc] initWithLowerTriangularArrayType:NumericalArrayTypeFloat array:theValues rows:5 columns:5 orientation:NumericalArrayOrientationColumnMajor]; NumericalArrayDS* theDS; NSDictionary* attrs; theDS = [[NumericalArrayDS alloc] initWithNumericalArray:theArray]; [theArray release]; attrs = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:100],NumericalArrayDSMaximumColumnWidthKey, [NSFont userFixedPitchFontOfSize:12.0f],NumericalArrayDSFontKey, nil]; [theDS bindToTableView:theTableView displayAttributes:attrs]; }
Which would yield something akin to this:

Both the source code and a complete sample Cocoa project are available.
  • View the header file.
  • View the source file.
  • Download the sample XCode project.
winfo
Just added: winfo is a very simple little utility that uses the IOKit and SystemConfiguration APIs to print a little bit of info about the state of a wireless interface. For example:
% winfo usage: winfo <interface> <interface> = BSD network interface (e.g. en1) * adapter interface flags can be found in /usr/include/net/if.h * mode flags can be found in /usr/include/net/if_media.h % winfo en1 { wap: "UDel" [channel 6] [XX:XX:XX:XX:XX:XX] en1: [XX:XX:XX:XX:XX:XX] mode: <auto> (0x00000080) | flags: 0x00008863 | power: on }
Both the source code and a Universal binary are available for download.


Mac OS X 10.4
  • Download the gzipped Universal binary.
  • Download the tarred, gzipped source code.


Mac OS X 10.5
Making Good Use of launchd on Mac OS X: svnserve and PostgreSQL
I finally got around to switching to Subversion after being a long-time user of CVS for my revision control needs. But getting daemons and services running under Mac OS X can be a bit of a pain. With a little reading of the man pages for launchd.plist, though, I was able to quickly and easily get the service setup.

First and foremost, be sure you've opened-up the svn ports on your firewall. Yes, you should be running the built-in firewalling, and yes it's trivial to add UDP and TCP ports 3690 in the Sharing control panel.

The following property list assumes that I've got my svnserve executable installed in /usr/local/bin:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <false/> <key>Label</key> <string>subversion.svnserve</string> <key>ProgramArguments</key> <array> <string>/usr/local/bin/svnserve</string> <string>--inetd</string> <string>--root=/Users/frey/Source</string> </array> <key>ServiceDescription</key> <string>Subversion Standalone Server</string> <key>Sockets</key> <dict> <key>Listeners</key> <array> <dict> <key>SockFamily</key> <string>IPv4</string> <key>SockServiceName</key> <string>svn</string> <key>SockType</key> <string>stream</string> </dict> <dict> <key>SockFamily</key> <string>IPv6</string> <key>SockServiceName</key> <string>svn</string> <key>SockType</key> <string>stream</string> </dict> </array> </dict> <key>inetdCompatibility</key> <dict> <key>Wait</key> <false/> </dict> </dict> </plist>
Enter this in a text editor and save as /Library/LaunchDaemons/subversion.svnserve.plist (or use the Property List Editor app and save, likewise).

It's always best to create a dummy account to store your repository, and run svnserve under that username/group. There are keys you can add to this plist to specify under what user (the UserName key) and/or group (the GroupName key) the daemon should be run. By default, the user and group of the person who actually loaded the daemon into launchd will be used; I'm guessing this means if it loads at boot time, root would be used.

While I'm at it, how would you like a launchd plist for PostgreSQL? Assumes you've got a user and group named postgres and that the executables are in /usr/local/pgsql/bin:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <false/> <key>EnvironmentVariables</key> <dict> <key>PATH</key> <string>/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/pgsql/bin</string> </dict> <key>GroupName</key> <string>postgres</string> <key>Label</key> <string>postgres.postmaster</string> <key>OnDemand</key> <false/> <key>ProgramArguments</key> <array> <string>/usr/local/pgsql/bin/postmaster</string> <string>-D</string> <string>/usr/local/pgsql/data</string> </array> <key>ServiceDescription</key> <string>PostgreSQL Database Server</string> <key>StandardErrorPath</key> <string>/var/postgres/logfile</string> <key>StandardOutPath</key> <string>/var/postgres/logfile</string> <key>UserName</key> <string>postgres</string> </dict> </plist>
Enter this and save as /Library/LaunchDaemons/postgres.postmaster.plist. Next reboot postmaster will be launched immediately, with all logging pointed at /var/postgres/logfile.

In either case, if you want to activate the service immediately and without rebooting you have to inform launchd of the new addition:
% sudo launchctl load /Library/LaunchDaemons/subversion.svnserve.plist
Since the svnserve service is setup to be run on-demand, launchd will listen for incoming requests on the standard SVN port (see /etc/services) and run our command and arguments accordingly. In other words, you won't immediately see any svnserve processes running! The PostgreSQL service, on the other hand, should start immediately once you load it, and a ps -aux | grep post will show you that you got it right.

Incidentally, if you run launchctl without any arguments it will enter a command-line mode. Therein, you can list loaded services as well as start and stop them. Pretty neat; use Ctrl-D to exit out of its CLI.
Minicom: Build Info & Installers
Minicom 2.1 (rev 14)

Now that I'm working professionally on clusters and other "big" computer hardware is the ability to connect to console ports via my PowerBook. The Keyspan high-speed USB adapter will suit my needs, but I had to get Minicom compiled for Mac OS X 10.4. Binaries were available via Fink -- but that is huge overkill for me if all I want is Minicom (which is, itself, a mini code)! So I built the Minicom 2.1.14 program myself, and made myself a Mac OS X installer package.

The build script below should be executed within the minicom-2.1 source directory. It produces Universal Binary executables and libraries.

File Description
 minicom-2.1-14.pkg.zip
Minicom 2.1 Install Package (Universal Binary) for Mac OS X 10.4
 UniversalBinary.build
A script to patch and build Minicom 2.1 from the standard source

Minicom 2.2

The latest Minicom source (revision 2.2) also has some problems building on Mac OS X. These are the steps I had to take to get it to build and work:
% ./configure --prefix=/opt/minicom/2.2 --enable-lock-dir=/tmp % cd src % for file in config.c dial.c file.c help.c main.c minicom.c updown.c windiv.c window.c window.h; do > mv $file $file.old > cat $file.old | sed s/wprintf/mc_wprintf/g > $file > done % cd .. % vi config.h
You'll want to add this to the end of config.h:
#include <time.h>
Of course, you may or may not have a special --prefix for the ./configure. At any rate, after making these changes, do a make and make install, and the rest is configuration details.

File Description
 minicom-2.2.pkg.zip
Minicom 2.2 Install Package (Universal Binary) for Mac OS X 10.4