[% INCLUDE full_header.tmpl title="bits of code - sporkstorms.org" %]

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.

[% INCLUDE toprow_footer.tmpl %] [% WRAPPER firstcol.tmpl %] [% INCLUDE navbox.tmpl %] [% END %] [% WRAPPER secondcol.tmpl %]

sporkstorms

web-based content management (blog)

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.

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

Xchat Keyword Log

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

OpenLyrics.org

unfinished SOAP web service project

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:

Objective C HTTP client wrapper class

Objective C class

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)

IMDb to SQL

Perl scripts

Pipsqueek modules

Perl modules

[% END %] [% INCLUDE footer.tmpl %]