3/15/2005

Using Python to find Type/Creator codes

It has been a while since I needed to know about old-style Mac Type/Creator codes, but today I wanted to search my hard drive for files of a specific type. I thought you used to be able to drag a file into the find file Type box and it would automatically assign the Type to the input box, but this no longer seems to be the case on OS X.



I thought about downloading some utility which would allow me to see the Type code of a file of the same Type as the one I was trying to find, but then I realized I could probably do it with Python, and I was right.




>>> MacOS.GetCreatorAndType('/Volumes/Stormbringer/Audio/New Sessions/Guitar Project/Guitar')
('MOUP', 'PERF')


I also find myself occasionally using the Python REPL to do things like perform some quick math, convert between a char and the ordinal of that char, and look up unicode glyph names and resolve them. Instead of downloading some specific program to do some task, I have access to this vast functionality space which I can use to create my own utilities simply by remembering the steps to perform.



2/05/2005

Languages

I am always interested in new languages. I enjoy learning new ways of thinking about problems. While I was catching up on 6 months of unread NetNewsWire feeds, I read r0ml's post on languages and felt compelled to respond. r0ml doesn't seem to have comments or trackbacks enabled, but perhaps he'll see this in his referrer logs.



I was talking to a friend of mine about CPU megahertz, Moore's law and the laws of Physics, and the increasing need for programmers to be aware about concurrency. We started talking about one good way of scaling applications to multiple processors, vectorization. The first thing that comes to my mind when I think about vectorization (besides Altivec) is APL, thanks mostly to r0ml. So I did a search for "apl mac os x" and one of the first things that comes up is APLX. I don't know if r0ml has looked at this and discarded it as unviable or uninteresting, but it looks promising.



Smalltalk is another language that I like very much. The syntax feels so much easier to read. Smalltalk has historically not integrated well with it's environment. ambrai Smalltalk looks like it is on the way to fixing that problem. Not only does it very tightly integrate with the Mac OS X gui, it even appears to have command-line integration features.



9/26/2004

Nevow 0.3!

Nevow 0.3 is now out! Go get it!



There has been a lot of development over the past five months, and I have been feeling overdue for doing a Nevow release for a while now. So finally today I mustered the strength to write all the ChangeLogs, READMEs, and update the examples and documentation needed for a release. And what a release it is. This release encompasses some pretty major refactorings and additions:





  • freeform-patterns: This branch rewrote almost all of the freeform form rendering code (now called webform). It makes use of the Nevow pattern/slot paradigm to allow customization of the automatically generated forms down to the finest detail.

  • ubiquitous-context: This branch focused on making the Nevow APIs more consistent by passing a context object to the URL traversal APIs. Nevow keeps track of the objects involved in URL traversal and page rendering using a stack of context objects which you can use to make information available to your components.

  • LivePage improvements: LivePage is now cross browser! Mozilla, Firefox, WinIE6, and Safari browsers are all supported. Adding support for browsers such as Opera and Konqueror should be possible as long as they support XmlHttpRequest. Also, some python-side APIs were added which make mutating the in-browser DOM a breeze: set, append, alert, and call. All these python-side objects take stan, so you can pass them XML fragments composed using Python code or extracted from XML/XHTML documents. No JavaScript skills required!

  • New Fragment class: Fragment is a Page base class which implements just those APIs required to expose data_* and render_* methods in a stan tree. It's now easy to break out your frequently used components into self-contained classes, instantiate and return them from a Page.render_* method or even another Fragment.render_* method.

  • url.URL improvements: Some new APIs make it easy to manage view state using query arguments rather than server-side sessions, which expire and aren't friendly with the back button.

  • nevow.canvas: In the tradition of LivePage comes the experimental Canvas module, which gives you a server-side Python API for drawing lines, curves, and text in the browser, with control over line thickness, border color, and opacity. Canvas gives you a socket you can keep open as long as you need to draw animations in the client browser.

  • XML Compliance: xmlfile and xmlstring now properly retain doctypes, comments, and xmlns attributes.

  • IFoo(ctx) syntax: ctx.locate(IFoo) has been deprecated in favor of the more uniform adaption syntax IFoo(ctx).

  • WSGI Implementation: This release contains a simple, incomplete WSGI application implementation. It is now possible to use Nevow to render CGI or WSGI pages without Twisted installed.

  • guard improvements: guard.SessionWrapper now works properly when it is installed in locations other than the root.

  • Chatola: Chatola, the LivePage demonstration application, has bloomed into a fully operational web-based chat server!

  • inevow.IQ: The Interface for Querying is the beginnings of a DOM querying API. Currently, it contains only the patternGenerator, onePattern, and allPatterns APIs.




Visit the web site for more information about Nevow.



7/05/2004

Canvas

Dave Hyatt has been writing about the features which have been added to WebKit to support the Dashboard in Tiger, and today he writes about a spookily familiar new feature -- the canvas.



I say it is spooky because a few weeks ago, I had the great idea to expose the Flash MX drawing API to Python on the server side using Nevow. It really was a great idea, too. In less than a week, I had a working implementation and a nice demo application, which I wrote about here.



The original idea was not to specifically have Flash glue, but to devise a server side api for drawing which would use whatever client side drawing technology was available. I originally thought of SVG as the non-flash example, but the WebKit canvas would be excellent glue to write a Nevow canvas implementation with. It would provide some things that Flash currently does not (if only on Safari), such as better integration with actual HTML.



6/13/2004

Weird Weather

A few days ago, we woke up to 96 degree weather, with 80% humidity. This is a very rare thing for up north here. It wasn't stifling, although it was much nicer outside than in, so I decided to go for a little swim. It turned into more of a wade than a swim. Lake Superior always stays cold, no matter how warm it is out, and I couldn't bring myself to jump all the way in.



Within an hour, the temperature had dropped to 80 degrees. Within another hour, the temperature was 70. The change was so fast that I went from having all the windows and doors in the house open to closing them all.



Unfortunately, this phenomenon hasn't repeated itself. It has been overcast and in the 60s for a few days now. Today, I am going to drive down to Midland to stay with my Dad for a month, while Ari goes to California to help her parents move. It's amazing what a difference a four hour drive makes. We'll certainly be needing the air conditioning this summer.