sporkstorms.org
sporkstorms.org miscellaneous code bits software photos
don't touch that dial!

code bits

Here you'll find various bits and pieces of code that I think others may find useful. They aren't full-fledged software, and aren't likely to be useful to you if you're not a programmer.

All of this software is free. You can use any of it under the terms of the LGPL.

XML::Atom::ToRSS and XML::RSS::ToAtom Perl modules

Perl modules

Modules for to convert Atom feeds to RSS, and RSS feeds to Atom. Includes example scripts, and regular distribution (like those from CPAN. Just run perl Makefile.PL; make; make test; make install)

The modules are even documented. After installing them, you can use perldoc to view the documentation.

Here's a demo of a simple web script using the modules

Download atom_rss.tgz

sporkstorms

web-based content management (blog and template serving)

These are the templates, Perl code, mod_rewrite rules, etc that I use for this site. It was hacked together in a few minutes using bits and pieces of the various CMSs I've written.

browse the files
download tgz

Pinyin to Unicode tone marks in Objective C

Objective C class

This was written for Yafca, but you might find it useful for other applications. It converts Pinyin marked with digits to proper Unicode with accent marks. (example: "zhong1 wen2" becomes "zhōng wén")

download the files
example.m shows how simple it is to use this class.

Arrow buttons with Cocoa

Objective C class

If you want an NSButton to respond to the arrow keys, your first instinct will probably be to simply use setKeyEquivalent:. Unfortunately, it's not this simple. If you've tried this, you found that the button "clicks" twice every time you push the arrow key. This is because the button responds to both NSKeyUp and NSKeyDown.

To work around this, I created a simple subclass of NSButton that ignores NSKeyUp. To use it follow these steps:

  • download ArrowButton.h and ArrowButton.m
  • add them to your project
  • #import "ArrowButton.h" where it'll be needed.
  • in Interface Builder, make a subclass of NSButton called ArrowButton; set your button's "Custom Class" to ArrowButton
  • In an awakeFromNib, invoke [theButton setType:aType] where theButton is an outlet to your button and aType is one of ArrowButtonTypeLeft, ArrowButtonTypeRight, ArrowButtonTypeUp, or ArrowButtonTypeDown
  • If you require a modifer, invoke [theButton setModifierMask:modifierMask] where modifierMask is one of NSShiftKeyMask, NSAlternateKeyMask, or NSCommandKeyMask. It is important that you use this method instead of NSButton's setKeyEquivalentModifierMask: so the object knows how to parse and handle the event, which is critical if you want, for example, a button that handles the right arrow, and a button that handles command + the right arrow.

Menu in an NSTableView

Objective C class

This class allows you to have pop-up, context menus within an NSTableView (when you right click, for example). It is pretty simple; Have a look and you should be able to figure it out.

I used this class in CocoaCEDICT, where you can see it in action.

Objective C HTTP client wrapper class

Objective C class

Update: Well, it seems Apple finally added a proper way to do this in Objective C using NSURLConnection. They've added + connectionWithRequest:delegate: and - initWithRequest:delegate:. I'll leave this here anyway, in case you find it useful.

NSURLConnection is entirely worthless for making asynchronous POST requests (probably GET too?). So, I wrote my own wrapper around the Core Foundation's HTTP functions. It's not going to handle anything fancy (like authentication), and isn't meant to. It's served its purpose and done so admirably.

Before you even try to mention CURLHandle... I hate curl, so naturally I hate that bloated wrapper around libcurl (don't even try to reason with me on this :-p)

Download DAClient.h and DAClient.m

cd to current Finder directory in iTerm

Automator Finder Plugin

This Automator action is to be used as a Finder plugin. It opens a new iTerm tab/window for each folder selected, and cd's to the selected folder. If the selected item isn't a folder, it cd's to the folder that contains that item.

  • Double click the cd_in_iTerm.dmg disk image to mount it.
  • From your home folder, make the following hierarchy of folders if it doesn't already exist: Library/Workflows/Applications/Finder
  • Drag the cd in iTerm.workflow workflow into the Finder folder you just created.
  • Now you can select files or folders in Finder, right click, go to the Automator sub-menu, and select cd in iTerm

download disk image

tar and gzip selected items in Finder

Automator Finder Plugin

This Automator action is to be used as a Finder plugin. It tars and gzips all selected files and folders.

  • Double click the tgz folder.dmg disk image to mount it.
  • From your home folder, make the following hierarchy of folders if it doesn't already exist: Library/Workflows/Applications/Finder
  • Drag the tgz.workflow workflow into the Finder folder you just created.
  • Now you can select files or folders in Finder, right click, go to the Automator sub-menu, and select "tgz"

download disk image

randomize_rss.pl

Script to randomize OS X RSS Visualizer screensaver

This goes through all of the available RSS feeds in your Safari bookmarks and randomly sets one as the feed for your RSS Visualizer screensaver (included with OS X 10.4)

If you're not familiar with the shell, I recommend you stick this in an Automator workflow. Choose Automator under Applications, then choose "Run shell script." Give it the path to the file, save it, and you'll be able to simply run that automator action.

download randomize_rss.pl

Applescript

(better) combine Safari windows

AppleScript "Script Menu" script

Apple's script menu comes with a script to combine all browser windows into a single tabbed window. It only combines the front-most tab of each window though, making it entirely useless to me. So I fixed it. This script combines all tabs in all windows into one tabbed window.

Caveats - Safari's "always show tabs" option must be enabled, GUI scripting must be turned on, and (obviously) the script menu must be enabled.

Stick the compiled script in ~/Library/Scripts/Applications/Safari/ (that's the Library in your home folder)

download the compiled script or its source

IMDb to SQL

Perl scripts

Converts the arcane IMDb data dumps to SQL.

TODO: upload & link

Pipsqueek modules

Perl modules

Modules for shaun's bot, Pipsqueek

TODO: upload & link

Xchat Keyword Log

semi-unfinished OS X application (ie: mostly finished)

TODO: upload & link

OpenLyrics.org

unfinished SOAP web service project

openlyrics.org

TODO: describe and status