8 Posts for August 2007


Posted August 30, 2007

Jay Phillips has just released a terribly snazzy new Ruby package, called “Superators.” Check out his post if you want the full scoop, but the gist of it is that you can define certain operators that aren’t explicitly built into the language.

Some of the examples he gives are <---, -~+~-, and ++. A commenter suggested =|===- as a “ninja sword” operator. The general rule is that you can take any pre-existing infix operator and append +, -, or ~ to it any number of times.

The most amazing thing about this is that it’s done in pure Ruby. There’s no parser redefinition or syntax-tree crawling. Just some terribly clever hacks.


No More RSS

Posted August 27, 2007

As a notice for those of you subscribed to the RSS feed: in about a week, I plan to get rid of it.

Don’t panic, the Atom feed will still be available. In fact, the URL for the RSS feed will point to the Atom feed. It just won’t be RSS.

I have a couple reasons for doing this. First of all, it’s kind of silly to support two different feed formats. They both show up the same in the reader.

How I Wrote an Emacs Blog Client (And Lived to Tell the Tale)

Posted August 24, 2007

As I hinted in my last post, I wrote it from within Emacs. This entry, too, is being composed in the text editor extrordinaire. This shouldn’t come as much of a surprise. There are clients out there for Blogger, Livejournal, the more generic Atom API, and probably others well.

What’s cool about it, though, is that my blog is neither hosted by a blog host, nor does it implement Atom. I had to write my blog-from-Emacs code from scratch. This is my story.

What first inspired me to write the Emacs-blog-poster was a snazzy Emacs Textile-mode which I happened across and installed. I write my blog posts in Textile, so the prospect of having them syntax-highlighted, not to mention not having to deal with Firefox’s text area UI1, was pretty cool.

For a while, I’d write my entries in Emacs, then copy them over to the textbox to preview them. Then I’d switch back to Emacs to make any edits I needed to, then copy it back to the webpage, over and over again.

Editors, Emacs

Why I Use Antimacs

Posted August 21, 2007

By way of introduction, Antimacs is a text editor. No more, no less. It doesn’t try to cram in features, nor does it succumb to the temptation to stray away from its purpose. It edits files, and that’s all that it does.

There’s no way to write email in Antimacs, nor can you play tetris. You certainly can’t chat with an AI psychoanalyst1. That would just be feature bloat.

Antimacs is written from ground up in straight C. This may sound limiting, development-wise, but it’s extensible in Lua. There’s a Textmate-style file pane plugin available, and one that lets you open up a Lua console.

New Blog Features

Posted August 18, 2007

I promise I’ll stop talking about the blog pretty soon. But I just added some new features I wanted to talk about.

First of all, the post URLs are now pretty. For example, instead of /posts/23, this is now /posts/23-new-blog-features. This is mostly because I was getting annoyed looking at Google Analytics and being unable to remember which links went to which posts.

Actually, the pretty-URL thing has been around since the big major update, but it wasn’t as visible as it is now. Links from the front page used the pretty URLs, but links from the feeds didn’t. That’s fixed, now.

Luckily, the old URLs didn’t cause any compatibility issues. /posts/23 goes to the same page as /posts/23-new-blog-features. In fact, it doesn’t matter what you put after the number; /posts/23-the-way-you-can-go-isnt-the-real-way goes to the same place as well. This is so that, in the event that I change the title of one of the posts, the old URLs don’t break.


Posted August 15, 2007

In the two years I’ve been at the university, I’ve taken a few classes on literature. These have been very enjoyable; essentially, literature class teaches you how to analyze things, how to look at their details and understand them in a more in-depth manner than you normally would.

The fact that literature is the subject of this analysis is more or less incidental. It’s handy because books (at least those that are well-written) generally carry many layers of meaning and tend to be fun to read. Really, though, we could be analyzing films, advertisements, even comics1, and it wouldn’t matter; the basic principles would be the same.

You could even analyze code. I think that would be quite an interesting exercise; take a chunk of code and subject it to literary analysis. There’s actually a strong mapping between code and prose. If the code won’t compile, that’s a grammar mistake. A logic error maps on to a mistake in an argument or a plot hole.

Blog, Rails, Testing

New Blog! (Really This Time)

Posted August 11, 2007

Today, as it happens, is my birthday. I’m not telling how old I’m turning, but I will say that I hadn’t yet wrapped my mind around my last age change. Time moves to quickly for my tastes.

Anyway, as a gift to myself, I decided to finally put the finishing touches on my new blog. I wrote the last few tests, battled for a while trying to get it working on the server1, and now here it is, all shiny and new! What do you think?

Well, I’d imagine you don’t really think all that much is different. There are some small things, though. The sign-in glyph in the upper-right-hand corner has changed2. The UI for previewing comments is a little slicker. Various stylesheet improvements have been made.


Posted August 6, 2007

Something’s been bothering me for a while about Rails models. Instead of talking about the bother immediately, though, I’d like to give some context, to go over the line of thinking that led me to it. Hopefully this’ll also serve to explain why I find the issue so bothersome, and if I’m lucky it might inspire some of you to help me solve it.

People have been saying recently1 that business logic doesn’t belong in controllers. Controllers should be “thin.” They should really only serve to push data around. This data goes to that view, that data is passed to these attributes, that sort of thing. I find myself agreeing with this philosophy; it seems to result in cleaner code all around. Not just in the controller, but also where the logic ends up.

The philosophy is also vocal about where this should be: the model. Models should be “fat.” Using the power of advice2, this is reasonably straightforward. Instead of the controller running this blog post through RedCloth in the show action (which is called when you go to /posts/20), for example, the model runs it through when the render method is called.

This has all sorts of advantages. I can access the rendered content from places other than the one action. If I suddenly have more than twenty readers, I can optimize by pre-rendering the posts and nothing but the model will change. “Thin controllers, fat models” is clearly useful.