Archive for the ‘Geek Shit’ Category

Settling in..

Wednesday, August 22nd, 2007

Update: I've ditched the Mac OS Classic theme in favor of a custom theme, so I have a little more control over the sidebar..

Well, so far so good. I'm really enjoying the admin interface of WordPress. It's an interesting look at just how far my software needed to go. It's just beautiful. You'll notice a few things about the new 'blog..
(more...)

I have succumbed..

Wednesday, August 22nd, 2007

After YEARS of using my own 'blog software, I finally succumbed to the allure of WordPress.

I blame this goddam theme. I love it so much. Plus, now I'm getting excited about playing around with plugins, and seeing if I can plug the thing into my favorite text editor. So, I'm sure in no time, I'll have made this blog as much my own as the old one. Plus, it'll be a lot easier. The old 'blog was still a fantastic learning experience, and I'd STILL like to make use of the code. For now, though, it'd be nice just to be able to concentrate on writing more.

Let me know what you think! :)

Sharing the AppleScripty Goodness

Wednesday, October 11th, 2006

Sharing the AppleScripty Goodness

A new app with an Old School feel

So, I found my favorite application of all time today. Seriously. I can't believe I'm posting twice in the space of a week on text editors, but such is the predicament in which I find myself.

Last week was writely - this week, fuck writely, and long live WriteRoom. Actually, that's not really true. I think writely has its place, but this thing is just so goddam great.

To give credit, I should mention that I found this, of course, through the venerable digg.

The best way to explain WriteRoom is to do so in the creator's own words. From the site:

For Mac users who enjoy the simplicity of a typewriter, but live in the digital world. WriteRoom is a full screen, distraction free, writing environment. Unlike standard word processors that focus on features, WriteRoom is just about you and your text.

That almost sums it up. I'll explain it this way: For any old timers who ever worked on an old monochrome screen on any system.. You will love this. You start up the app, all is fairly normal, if a little stripped down. You're given a little black window (which looks a LOT like a green on black terminal window) which turns out to be the text entry area. This is the simplest text entry area you can imagine. Imagine TextEdit.app (or, notepad, if you must, windows weenies) but, without the bells and whistles. Heh. This is simply a window where you can put in text. A quick look in the preferences shows that you can change a few basics: Display Font, Background Color, etc. However, that's really pretty much it (I use Georgia, by the way, the same font you're reading this in now). So, you type in your text, it looks nice and simple, but you still haven't seen the thing that makes this little app truly great. When you hit escape, it shows its true colors.

Suddenly, instead of a little black window floating on top of all your desktop clutter and the clutter of all your other running apps, you have a beautiful, empty black screen, with your text dead center.

You and your text. Nothing else. Pure simplicity. Hence the distraction free in the description from the website. I find this so completely comforting. I can't explain how soothing the feeling is. Sitting here writing on my iBook, with nothing but a black screen full of text in front of me. It makes writing simple text a completely immersing experience, rather like the experience of playing a FPS game in full screen. Mostly, though, it takes me back to the old days of writing school assignments on my old 8086 amber mono POS. Back when the world was simpler..

The AppleScript bit

Ohhh yeah. I almost forgot. There's an AppleScript component to this story. Well, as my avid readers will know, I wrote myself a quick AppleScript to upload simple text documents from TextEdit.app to my 'blog using the Blogger API. I knew if I was going to get any use whatsoever out of this beautiful little app, I was going to have to be able to write a similar script.

Luckily for me, the lovely people at Hogs Bay Software thought of situations just like this. A quick look in the plugins section got me a WriteRoom -> Email script which I was able to easily merge with my TextEdit blog script to create a whole new animal: A WriteRoom blog upload script. Eeeexcellent. The best part is, because WriteRoom has great AppleScript integration, it only took me a few more lines to adapt my old script to work. Most pleasing.

I've already uploaded my script to the Hog's Bay forums (gotta give back, yo). But, I'll reproduce it here as well, for the sake of completion.

PS - for you windows weenies, some benevolent windows weenie programmer has created a windows version named DarkRoom. Of course, my script won't work with it, but, hey, at least you get the old school word processor experience.

My script (Enjoy!)


-- change blogServer, xmlApplication, username, and password to your server settings
set blogServer to "your.blogserver.com.au"
set xmlApplication to "/blogserv/xmlrpc.php"
set myUsername to "username"
set myPassword to "password"
set postURL to "http://" & blogServer & "/blogserv/entries/"

global blogServer
global xmlApplication
global myUsername
global myPassword
on getUserInfo()
set myApplication to "http://" & blogServer & xmlApplication
using terms from application "http://www.apple.com/placebo"
tell application myApplication
set retVal to �
call xmlrpc {method name:"blogger.getUserInfo", parameters:{myUsername, myPassword}}
end tell
end using terms from
return retVal
end getUserInfo
on newPost(content)
set appkey to "dummy"
set blogid to "dummy"
set myApplication to "http://" & blogServer & xmlApplication
using terms from application "http://www.apple.com/placebo"
tell application myApplication
set retVal to �
call xmlrpc {method name:"blogger.newPost", parameters:{appkey, blogid, myUsername, myPassword, content, 0}}
end tell
end using terms from
end newPost

tell application "WriteRoom"
set my_document to the document of window 1
set my_content to the text of my_document
set my_title to the name of my_document
set my_title to text ((offset of ":" in my_title) + 2) through (the length of my_title) of my_title
end tell

set wholeContent to ("" & my_content)
set postID to newPost(wholeContent)
do shell script "open " & postURL & postID

The Return of Applescripting

Tuesday, September 19th, 2006

A bit of background

So, years ago when I first started this site, it was always intended to be more of a geek exercise than anything. I wanted to have my own blog software - which I now do - which had a native client on the Mac. As it happens, I actually accomplished all that in a relatively short time. The Mac client, largely due to the ease of native development on the Mac (go Applescript studio!) was surprisingly easy, being that it was my first GUI application. I was pleased with my work, and began to use the blog (somewhat sporadically, I admit).

Fast forward three years and three macs later.. Due to a messy incident involving a tattooed developer, the main backup of my original Mac client code base disappeared (you'd think a sysadmin like me would be better about keeping backups.. I may have one around here somewhere, now that I mention it). Thus: I've lost that original client.

A new old objective

Naturally, now that I've done all these great enhancements to the server code, it got me thinking about having a proper Mac editor to save me having to use a crappy web browser text entry interface. Thus, I decided to have another try at a Mac client. This time, though, I wanted to get back to my original idea: What I wanted, years ago, was to be able to author a document in a basic text editor - say.. TextEdit.app, which ships with Mac OSX - and run a quick script to upload the saved document as a new blog entry. No sexy features, no editing, no bullshit, just a simple way to upload text from a simple text editor to my site as a blog entry. Unfortunately, at that time, my Applescript chops weren't quite up to the task of scripting TextEdit to do the 'blog dance (not to mention the XMLRPC support in AppleScript wasn't too crash hot either). Also, although I wrote my server, the actual API calls to create entries and such were a little needlessly tangly (due to the fact that I didn't bother to learn much about XML-RPC, I just used libraries to get the job done. Sue me :P ). Thus, at the time, funnily enough, it was actually easier to write the full-fledged application for blog entries.

We say yes to standards

Of course, being that I wrote that original client 3 years ago or more, I had absolutely no memory of what was involved to get it up and running.. So, back to the web. Luckily, Apple's support for XML-RPC has grown in the intervening months and years. In fact, now all that is required to perform XML-RPC calls is a few native AppleScript calls. Apple seem to have fully adopted XML-RPC and SOAP, and even included native functions to support both (something few, if any, other, supposedly superior, languages can boast currently).

Awesome.

It turns out that Apple aren't the only ones lately who have warmed to XML-RPC as a standard. In the last few years, virtually every major "community" site on the 'net has begun to integrate with blogger, TypePad, and WordPress. I wanted to tap into this.. Badly. The short answer, of course, would have been to download an existing blog server (like WordPress) and run my blog that way. But, that's not really my style - obviously. Thus, I decided to tack a standard API on to the side of my blog. The big advantage to doing things this way is that I actually had to do very little work, and I didn't have to change much. The existing blog functions still work, as they haven't been touched. In the space of one new file I was able to give the world access to my blog. Now, I can easily click on "blog this" links on several sites (including, of course, my current faves, flickr and digg) and.. bam! A new blog entry. Dead sexy, and quite useful. A nice combination. All thanks to my, and the community's, willingness to adopt a standard programming interface.

Documentation is for pussies.

The really great thing about standards, is that there are so many of them..

Whoever said that was a pretty smart guy. I'm not going to spend a lot of time beating a horse that has been well and truly bashed to death all over the 'net.. But, just let me say.. FUCK!

Of course, saying that I just "tacked on" a blogger interface is putting it far too simply. I originally started out trying to implement the MetaWeblog API (MWA). This turned out to be almost too much for my little brain, let me tell you. The only "real" documentation I could find, turned out to be a custom implementation (read: Lots of little changes that make a really, really big difference). So, that quickly died. I initially wanted a very "robust" API - something that would allow me to start using multimedia content, and storing it alongside entries, for use in different areas of the site. MWA promises all this, but apparently at the expense of your sanity (not to mention any semblance of a social life, as I spent the better part of a week of evenings getting absolutely NO WHERE with the fucking thing). At least with the blogger API, there was a very, very nice page describing the entire "conversation" between server and client in detail.

So, I changed tack. I opted for the smaller, simpler and, probably most importantly, slightly older Blogger API. In standard "IT" terms, this was probably not a great decision on paper. The API is aging, and formal support for it is bound to be dropped by it's originators, who have moved on to Atom (a topic I'm not touching just now - let's just say it's 10x as frustrating as MWA). Those two points alone are enough to send your standard IT management weenie running for the hills. That thought occurred to me, shortly before a couple of other points occurred to me: a) Aging API = Legacy (also usually a bad IT thing) = Well tested and accepted. and b) fuck IT management weenies and the gantt chart they rode in on. Using the blogger api didn't offer a hell of a lot of sex factor, but it sure got me up and running. The night I decided to switch to the blogger API, I was posting from flickr to my blog in the space of several hours. Much better.

It's worth mentioning at this point that I could never have gotten there without a trial version of the fantastic, full-featured Mac-based blog editor ecto. In particular, the "console" feature allowed me to see the exact conversation going on between my test server and the client itself. Armed with that, and the aforementioned excellent documentation for the blogger API, and I was bound to get there in no time.

Full Circle

So, once I had blogger support working (plus blogger2 support, which I had to add for digg to work - yay standards) I cruised along.. Happily posting pic after pic from my collection at flickr, and happily clicking "blog this" over and over at digg. That's been a couple of weeks now, and I've been very happy.. But, back in my brain, where the real work goes on, I still had that nagging sensation that I was missing something.. Every time I had to go into my online blog editor to create a new entry, I felt a little pang.. The time had come.

That brings us up-to-date to a few days ago. I sat down and had a quick look at the current state of AppleScript XML-RPC support. I also fleshed out the basics of how to grab the text of a document in TextEdit along with a document's name to be used as the title. That part turned out to be disgustingly easy. I don't know if I've just gotten that much better at AppleScript since the last time I looked at this silly idea or what, but that part, which once seemed so daunting, took mere minutes. All that was now required was to glue the two pieces together: Grab the text content of a TextEdit document, along with it's name ,and send the two off to a blogger.newPost call on my server. Sounded easy. Was easy. In fact, the whole thing is taken care of in just under 60 lines of code (see here).

The code is, of course, a dirty hack. In particular, it doesn't address the problem of multiple users, and setting up and saving passwords in an easy gui. But, hey, give me a break here. This was five minutes worth of code. Five minutes for fuck's sake. Total jackpot. Three years into my great adventure of writing the blog software and wanting a quick, easy client based on TextEdit has finally come back around. I could not be more stoked.

the long and the short of it

Actually, this is the short of it. Every thing above this is the long.

I'm so amazed at how easy this was, after having been such a long journey. I love that things have gotten to a nice "lowest common denominator" with regards to blog software, and that I was able to pick it all up in a relatively short amount of time. In particular, I love that my blog server is now "standards compliant" and ready to have other pieces of software easily talk to it.

What next?

Next. I'm thinking a lot about it, without having actually moved anywhere (give me a break.. in the last few months, I've managed to learn ajax, blogger api and a whole lot more about XML-RPC internals. Not too bad for a guy who doesn't make his living as a developer). I think I will probably break down and add a more "modern" interface to the server. People aren't going to keep supporting the blogger API forever. In particular, the built-in blog client in my new favorite browser Flock only supports Atom or MWA. That alone would probably be enough reason for me to go ahead with it. I've just got to find some decent god damned ape-raping cock-sucking documentation on either one of them (fat chance. sigh).

I'm glad I got that all out. I'm getting ready to hit the "upload" button, and transform this article from it's lowly beginnings as a TextEdit document into my next 'blog entry.. Wish me luck.