======= Hacques ======= :author: bbum_ .. Contents:: Introduction ------------ This directory contains random projects and chunks of code that either solved some random problem or were created to explore something. For the code to be here, it "worked". The definition of "work", however, may range from *rendered a useful application that I rely upon daily* to *demonstrated that some random bit of API can or cannot be exercised in a particular fashion*. I will try to denote what definition of "work" any given production falls under as that may be of interest to others. DeDat ----- Works Stable. Double-clickable app that I use semi-regularly. Has lived in my *Applications* directory unchanged for a couple of years now. Purpose A small PyObjC application that rips apart ".dat" attachments so often barfed up by certain [mis]configurations of various Microsoft email programs. Drag and drop a ".dat" attachment from Mail or Finder onto the Target presented by the app. DeDat will then unarchive the attachment and display a list of the contents which can then be double-clicked or displayed in the Finder. History DeDat was written in the 10.1 timeframe. I was working with a lawyer whose firm had an email system that insisted on putting *everything* into ".dat" files. It has been upgraded to be an Xcode_ project and now uses the embedded Python interpreter for launch speed, but does not leverage Cocoa Bindings or a number of other modern features that were not supported until later versions of PyObjC_. Of Note - DeDat is really just a wrapper around the tnef_ command line tool. - The *Target.pdf* was produced by `Stone Design's Create`_. - The app icon is a photo of a wildflower growing around the house when I lived in Connecticut. I can't remember what it is called. Yes, that is an ant crawling around inside it. I thought it was fitting because "ants crawling all over me" is often how I feel when dealing with certain lawyers and/or data formats. DropInspect ----------- Works A developer tool that solved the problem at hand, that's it. Explanation DropInspect is a PyObjC based application that accepts drag-n-drops of many `standard pasteboard types`_. Upon the drop, DropInspect displays a table of all of the types that were found on the pasteboard. If a type includes an 8 digit Hext number, it is assumed that it is a 4 character type code and a second column displays the type. Any one pasteboard's contents can be dumped to the console by pressing a button. The app also accepts pasteboards by paste. That is select anything in any application, click on the DropInspect window, and paste. DropInspect does not have any knowledge of the types on the pasteboard. That wasn't a part of the original problem. History DropInspect was written during a Cocoa/Java project to figure out how to accept drag-n-drops from some other application outside of my control. I knew one type on the dragged pasteboard, but that one type was not the type I really needed. So DropInspect was created as a generic way to introspect pasteboards. It has proven intermittently useful over the year(s). I think it was originally written in the late 2002 or January of 2003 timeframe. WordLabelHtml2vCard.py ---------------------- Works Solved the problem of freeing our family's mailing labels from Microsoft Word documents configured for label printing. Explanation Microsoft Word has a document format that is designed for printing labels. You type in a bunch of addresses into the label boxes and it prints them. We had been using this to store all of our family labels-- holiday lists and the like-- for years and wanted to import all of the data into Address Book. Save Word label documents to Word HTML format (not HTML archive) and then parse the resulting HTML file with this script. It will write a file containing vCards for all of the addresses found within the HTML. The script is a one off optimized for our particular set of addresses. It worked well for us, may not work so well for others. I tossed it into subversion because I will apply patches and maintain it if others find it useful. Of Note - Word's HTML format was used as a data interchange format because it is consistently structured and easy to parse. - Regular expressions are used to try and break apart city, state and zip. - There are lots of little special case type stuff for removing noise that I found in the data stream. You may encounter entirely different noise. - The script is very poorly written. It is a one off and now that the data is freed from the confines of a Word document, I'll hopefully never have to run it again. Miscellaneous ------------- proplist.py +++++++++++ Reads an XML style Property List from Foundation turns it into a set of Python collection classes. Will decode binary data. pdf2png +++++++ Converts PDF documents to PNG images using the Quartz Python bindings found on Mac OS X. Works best with screenshots taken on Panther. It will write multi-page documents to multiple PNG images, one page per image, but the rendering isn't very clean. I have no idea why as converting screenshots to PNG was the problem to be solved. httpflow ++++++++ httpflow parses the output of tcpflow_ with the intention of reconstructing any captured http communications. It was a quick hack that was used to track down some cookie handling problems in a site that I was working on. It is also very useful for peeking at web service communications where the client application is relatively opaque. .. _bbum: http://bbum.pycs.net/ .. _Xcode: http://www.apple.com/xcode/ .. _PyObjC: http://pyobjc.sourceforge.net/ .. _tnef: http://sourceforge.net/projects/tnef/ .. _Stone Design's Create: http://www.stone.com/ .. _standard pasteboard types: http://developer.apple.com/documentation/Cocoa/Conceptual/CopyandPaste/Concepts/DataTypes.html .. _tcpflow: http://www.circlemud.org/~jelson/software/tcpflow/