One of the students in CSCS set up a Planet aggregator for the CSCS weblogs. As cs-ed.org runs on a small server, I’d rather not have a cron job running to do updates; instead, I prefer the pub/sub model, where the students with weblogs ping our server to update the aggregator.

Most weblogging tools have the ability to ping a weblogs.com-style XML-RPC endpoint. I thought I’d dissect how I implemented this, as it captures some of what I like about programming in Scheme.

I started with the bare minimum for an XML-RPC CGI process running under Apache:

#!/usr/local/bin/mzscheme -gqr

(require
 (lib "xmlrpc.ss" "xmlrpc"))

(xmlrpc-handlers

 (handler 'weblogUpdates.ping '...)
 )

I knew I had to provide the weblogUpdates.ping handler, as that’s part of the “spec”. Unfortunately, the spec calls for “optional” parameters, which the actual transport doesn’t support—but, I can fake it reasonably well with case-lambda. So, I’ll define my ping method, which will be exported to the outside world as weblogUpdates.ping.

#!/usr/local/bin/mzscheme -gqr

(require
 (lib "xmlrpc.ss" "xmlrpc"))
(xmlrpc-handlers

 (define ping
   (case-lambda
    [()
     '...]
    [(name url)
     '...]
    [(name url changeurl)
     '...]
    [(name url changeurl catname)
     '... ]))

 (handler 'weblogUpdates.ping ping)
 )

This also handles a non-specified case, which is when the procedure is called with no arguments; I added this for my own testing, and it happens to fit the needs of the particular project.

Now, when someone pings the server, I’d like to

  1. log the event, and
  2. run the aggregator

I actually started with the aggregator, but here, I’ll start with the logging. That would have made more sense, anyway.

#!/usr/local/bin/mzscheme -gqr

(require
 (lib "xmlrpc.ss" "xmlrpc")
 (lib "date.ss"))

(xmlrpc-handlers

 (define ping
   (case-lambda
    [()
     '... ]
    [(name url)
     '... ]
    [(name url changeurl)
     '... ]
    [(name url changeurl catname)
     (let ([op (open-output-file "ping.log" 'append)])
       (fprintf op "(~a (ping ~a ~a ~a ~a) (date ~a))~n"
                (current-seconds)
                name url changeurl catname
                (date->string (seconds->date (current-seconds)) #t))
       (close-output-port op))
     ]))

 (handler 'weblogUpdates.ping ping)
 )

It’s not pretty, but it gives me something to look at if I need to, or if I want to have a sense for how often people are pinging the aggregator. Because I want to have a human-readable form of the date, I have to import the date.ss library.

To run the aggregator, I need to import the process.ss library that lets me make external system calls.

#!/usr/local/bin/mzscheme -gqr

(require
 (lib "xmlrpc.ss" "xmlrpc")
 (lib "process.ss")
 (lib "date.ss"))

(xmlrpc-handlers

 (define ping
   (case-lambda
    [()
     '... ]
    [(name url)
     '... ]
    [(name url changeurl)
     '... ]
    [(name url changeurl catname)
     (let ([op (open-output-file "ping.log" 'append)])
       (fprintf op "(~a (ping ~a ~a ~a ~a) (date ~a))~n"
                (current-seconds)
                name url changeurl catname
                (date->string (seconds->date (current-seconds)) #t))
       (close-output-port op))

     (current-directory "/planet/")
     (system "python planet.py config.ini")

     ]))

 (handler 'weblogUpdates.ping ping)
 )

I’ve omitted the exact path in this particular example. Now, I fill in the ... I’ve had laying around, so that I have reasonable values for parameters that aren’t included. Also, the “spec” says that I should return a hash table indicating success or failure. I’m a bit lazy today, so I’m going to just indicate success all the time. I may revisit this and indicate success or failure based on the actual result of the system call.

#!/usr/local/bin/mzscheme -gqr

(require
 (lib "xmlrpc.ss" "xmlrpc")
 (lib "process.ss")
 (lib "date.ss"))

(xmlrpc-handlers

 (define ping
   (case-lambda
    [()
     (ping "none" "none" "none" "none")]
    [(name url)
     (ping name url url "none")]
    [(name url changeurl)
     (ping name url changeurl "none")]
    [(name url changeurl catname)
     (let ([op (open-output-file "ping.log" 'append)])
       (fprintf op "(~a (ping ~a ~a ~a ~a) (date ~a))~n"
                (current-seconds)
                name url changeurl catname
                (date->string (seconds->date (current-seconds)) #t))
       (close-output-port op))

     (current-directory "/data/www/cs-ed.org/cscs/planet/")
     (system "python planet.py config.ini")

     (let ([h (make-hash-table)])
       (hash-table-put! h 'flerror #f)
       (hash-table-put! h 'message "no error")
       h
       )]))

 (handler 'weblogUpdates.ping ping)
 )

And that’s it! In a handful of minutes, we have an XML-RPC endpoint that lets students tell the aggregator when they’ve updated their weblog.

It is interesting; I track a number of weblogs by Microsoft employees—mostly weblogs surrounding their development tools and the CLR, as that is in keeping with my research, and also in keeping with my interest in languages and their runtimes. What I think is interesting is that you occasionally find posts with notes like:

<shameless_plug> I’m looking for experienced industry candidates who are interested in joining our main campus teams in the Developer Division. We have openings for development, test, and program management. If you are interested, send me your resume (jasonz)! <shameless_plug>

While I’m sure these position announcements are available from a central source, Microsoft’s blogging program managers (I think) are putting the word directly out about the fact that they’re looking for team members. I think that’s interesting; it represents a change in the way things have traditionally been done.

Via Cringely:

Imagine a Mac Minicluster running Apple’s xGrid software. Start with a 16-port fast Ethernet switch and stack 16 Mac Minis on top. That’s a 720 gigaflop micro-supercomputer that costs less than $9,000, can fit on a bookshelf, and can be up and running in as little time as it takes to connect the network cables. High schools will be sequencing genes.

True. The question is: what do you use to program your brand-spanking new Mac Mini cluster?

A while back I was wrestling with getting Cocoa/Java apps to compile when using .jar files. I was trying to find a quick-and-dirty way to sketch up interfaces for applications, and then tie them together with an XML-RPC back-end running on localhost.

It sounds convoluted, but in conducting the data collection and analysis for my research, I already have thousands of lines of Scheme code that does a great deal of work. As I wanted a way to quickly browse through some of my data (visually), and I didn’t (at the time) know of a good GUI designer for MzScheme, I decided I could hack the front end in Java, do the GUI with Interface Builder, and *bing* the most convoluted app in the world would spring forth and help me be productive.

I had to move on, eventually, because it wasn’t worth the time I was investing. However, what I love about the WWW, and having an archive of posts, is that people have continued to leave notes re: the process on my post. Yesterday, Eric Esser sent me an email, tying together all the pieces in one place.

So. For your viewing pleasure, Eric Esser‘s Quick-and-Dirty, no warranties implied HOWTO compile a Cocoa/Java app on OS X using XCode and JAR files. Many thanks Eric, and hopefully I’ll put it to good use before the whole dissertation process is over and done with.

I came across your weblog on this topic as I was peeling my face off trying
to figure out how the heck to do exactly what you described in the post re
including a pre-built jar in with a simple java-cocoa app in xcode. It was
only through your comment section that I actually found my way to another
webpage that explains how to do this the “right” way.

I must say it is AMAZING that Apple doesn’t point this out. I’m having such
a hard time learning Mac development – it’s unbelievable how bad the
documentation is.

Anyway, it does indeed involve the copy files build phase, but it’s not
nearly as difficult as it sounds -

Presuming you’ve got a simply Java cocoa app project open in xcode 1.5:

0. First, add the JAR to the project using project>add to project . . .
From the menu. Doesn’t matter where you put the file.

1. On the left side, where they have the list of files, targets, etc, click
on the disclosure triangle next to the target of your choice (probably the
only target in the proj, if it’s a simple proj)

2. You’ll see a bunch of gray boxes – labeled something like “sources” and
“java resources” and “bundle resources” etc. Right click (or ctrl-click) on
the TARGET icon, and choose Add > New Build Phase > New copy files build
phase – that should make a new gray box at the bottom of the gray box list
labeled copy files. A window will also pop up that says “copy files info”

3. In the “copy files info” window, it has a pick down list for
“destination”, a “path” field, and a checkbox. Forget the checkbox. What
it’s asking for is “what standard location (i.e. The picks available in the
drop down box) in the bundle do you want to put the files listed in this
“copy files” phase (you haven’t listed them just yet), and where, within
that destination in the bundle, would you like exactly to put them. In
other words, the pick-down box is a list of standard bundle locations, and
you can further specify a path, relative to those standard locations. For
me, I chose executables, and left the path as “/”. That means “copy any
files listed in this build phase to the place in the bundle where the
executable files are located.”

4. Drag your added jar file (it will probably be up near the top of the
list, near the project name) down into the copy files area.

That’s it. Should work OK. By the way, the jar file doesn’t need to be
listed under any of the other build phases. I think xcode may plop it into
the “frameworks” build phase by default, but I just removed it from there,
because it actually wound up in my app bundle twice (once in the
“resources/frameworks” dir, where it did no good, and once in the executable
dir after I added the copy files phase).

You can check you work by right-clicking (or control-clicking) on the built
application bundle, and choosing “show package contents.” You’ll find that
the jar file is properly positioned in the MacOS dir, with the executable
file itself.

Hope that helps.

I’ve decided I like reading Media Matters. I’ve no love for bad reporting, and they do a great job of watching the people who should be watching the people in charge.

Or something like that.

For example, I hadn’t caught wind of the payments made by the RNC to Maggie Gallagher to promote and preserve marriage as an institution in America. That’s really sad.

But you have to find a way to, anyway.

Geoff Long took a look at our current logo efforts, and kinda thought they were a bit rough. After the swooshy design (see previous post), we moved on to a paisley fish:

20050125-fishy.jpg

The paisley fish is kinda rough, and we’re not sure what it has to do with a virtual machine for a concurrent programming language. However, CLJ and I thought the paisley was… well, it started as a school of fish, you see? And then there was this fill pattern, and … anyway.

Geoff kicked some ideas around on iChat with me, I bounced some things back at him, and he came up with the following two sketches:

transterpreter_logo_5.jpg

transterpreter_logo_5_horiz.jpg

I think they’re both great, and far better than our swooshy thing. Comments? Drop me a line at mcj4 at kent pbbt ac pbbt uk if you’ve got anything to say about them.

Incredible stuff, as always, Geoff. We’re definitely bringing two Mars bars with us to the States for you. That, or if there’s anything else you want imported, just let us know!

mars.jpg mars.jpg

Update: A few minutes later

I checked my mail, and found another logo! Officemate (Indespensible) Ed whipped up something that… well, it just brings tears to my eyes. What can I say.

translogoX01.jpg

It’s beautiful. Never have so few designed so much for so many… erhm, or something.

If you’re creating icons for OSX, Creating Photorealistic Icons for OS X is a handy resource.

We’re getting ready for a full release of the Transterpreter. Otherwise, my l33t art skillz would not be being brought into play at this moment. I’m kinda busy.

Our running draft of an icon:

transterpreter-logo.png

No doubt it will change. If anyone out there wants to have a go, we’re looking to capture the dynamic nature of writing programs in a concurrent programming language for systems (and little robots!).

Riiight. :)

Possibly, just possibly, we may have made a good decision about CSCS.

CLJ, Brad, are always shuffling about to try and find “the next cool thing” for CSCS. However, this (I think) has led to some loss of focus and/or direction. The students pick up on it, and we realize it. But it takes time to step away from the thick of it to figure out what to do.

Today, we just gave stuff away. We took all the robotics kit that we bought (well, most of it), and dished it out to students in the group. Rob and Steve made off with two Compaq 3600 handhelds, and are going to look at getting Linux installed on them (answer, Rob: yeah, sure–whenever. Tomorrow or sometime this weekend would be fine.) Others headed off with the Zauri and some Brainstems; yet others (including Brad and I) made off with a bot kit to put together the actual platform.

Access to equipment has probably been our largest problem to date. This, though, solved it (somewhat). We got kit in students hands, and now we do our best to support them in doing something interesting–like getting a new, homegrown robotics platform up and running.

In college, I had the pleasure of singing in a barbershop quartet with Dave, Brian, and Joel—we called ourselves Lost in Gambier. If you’ve ever been to Gambier, Ohio, you might catch the humor in the name. We performed for numerous college functions, and over the four years did hundreds of “singing valentines” in every nook and cranny of Kenyon you can imagine. We had a marvelous time, and I miss singing with them every now and then.

In England, I have had neither a copy of our CD nor MP3s ripped from it. While enjoying our five hour layover in Atlanta with Dave and Teena, I grabbed a copy of the disc from Dave; it was good that weather forced us into the odd travel arrangements we had, and we could spend that little bit of time with friends.

So, here is a recording of Irish Blessing in MP3 format from the self-titled CD “Lost in Gambier” by Lost in Gambier. One minute and thirty-three seconds long, it is a traditional melody and was arranged for four-part male voice Don Gray. It might be one of the strongest tracks on the album, or it might just be I’m partial to the song. Hard to tell either way.

May the road rise to meet you.
May the wind be always at your back.
May the sun shine warm upon your face.
And rains fall soft upon your fields.
And until we meet again,
May God hold you in the hollow of His hand.

Over at BFOP, we have this gem:


In FORTRAN tongue, the answer.

Google Scholar, huh? Well, let’s test it out.

[keyboard sounds]

Results 1 – 10 of about 1,800,000 for radiation.

[sounds of beer can opening]

[sounds of Kool & The Gang's "Celebration" being cued up on LP]

The only thing missing now is that little paper clip popping up in Microsoft Word saying, “It looks like you’re writing a dissertation. Would you like to use the Dissertation Wizardâ„¢ to provide the content?”