Blog Posts

Cunning Typo Sidebar Tricks

If you’re reading this on the website rather than through a feedreader and you look to the left you’ll see either a bunch of links to cited books or an Amazon ‘self optimizing links’ banner (though, if it keeps ‘optimizing’ like it has being I’ll be changing it to something else). This is implemented using a mildly hacked version of the standard typo amazon_sidebar plugin. “But,” I hear you say, “The sidebar’s over on the right, and Typo can only support one sidebar.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Typo Brain Dump

In case anyone’s interested, I’ve written a list of some of the things I’m currently mulling doing with Typo below the fold.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

You are in a maze of little, twisty evals, all similar.

Rails routing is making my head hurt. It’s starting to remind me of the guts of perl’s regular expression engine, which was said to be understood by three people, plus or minus five. I just want to write routes like /articles/:art[year]/:art[month]/:art[mday]/:art[slug]. I’m seriously considering starting again from scratch, which can’t be right.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

New Layout

You may have noticed I’ve been tweaking. The new layout is based on Scribbish with a few CSS tweaks and some low cunning to get the three column layout working. The basic font set is drawn from the new fonts that come with Vista: Body text is in Calibri, headings are mostly in Candara. I can’t say I’m a fan of Vista - I type this in a Windows free house - but the new font set is gorgeous.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

PragDave nails it. Again.

REST is easy, it’s just smart clients using HTTP to the full. Except, as Dave ‘PragDave’ Thomas points out, browsers aren’t smart. They’re just dumb terminals with prettier graphics. And what does that mean? It means that a typical Rails controller is trying to multiplex two protocols in the same chunk of code. There’s the pure four and then there’s the others: ;new and ;edit, offering up forms for clients too dumb to know how to build their own; and RJS helpers like ;preview, ;autocomplete and whatever else you need to do server side to make the Browser look smart.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Terminology counts

bq. All cultures develop their own vocabulary. If you were in a repair shop and you heard someone say “hand me that wrench with the knurled wheel that changes the width,” you wouldn’t want them working on your car. You want a mechanic who knows it’s a monkey wrench. - Kent Beck, Smalltalk Best Practice Patterns There’s not much I can add to that.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

The Authentication Fairy

If you haven’t yet read Ovid’s post about the ‘AuthenticationFairy, you should. Go on, you can rejoin me below the fold for discussion of some scary Perl…

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Must. Empty. Trash.

You know I said I was going to do some work with the Rails routing system And paint my office? And sort out all the crap in Gill’s office so she’s got a nice place to work? Well… Civ IV happened. Wow, I’d forgotten how much of a time sink the Civilization games could be. Frankly it makes World of Warcraft (another game I had to back away from before it took over my life) seem like a mere casual game.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Mmm... special!

Some months ago, I ordered a pizza from Papa John’s using their web interface (I’m not proud, I’ll admit to the occasional need for junk food). The pizza was terrible (since then I’ve only ever used them for a satsifying late night cravings for Ben and Jerry’s when I can’t be arsed to go to the all night Tesco’s). They still send me junk email. Today’s took the cake: To: Piers Cawley Subject: Papa John’s - Make your mum’s day Make your mum’s Day —————————————————————– Make mum feel special this weekend, buy any pizza and get another up to the same size and value HALF PRICE Only one online offer per order Because nothing says "

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

That's not fluent...

So, I’m not a fan of static typing. It’s okay in the likes of Haskell which does type inferencing and generally goes out of its way to reduce programmer pain, but Java? C#? No ta. It’s awfully tempting to conclude that anyone who chooses to use those languages deserves to be pointed out and laughed at. It’s especially hard to resist that temptation, when a C# blogger plays right into my hands by describing the following code:

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Cover me; I'm going in!

Mmm… Rails routes, don’t you love them? Well, not unreservedly, no. Here’s my current problem: Typo articles have a permalink that looks like /articles/:year/:month/:mday/:permalink, so the permalink for this article is /articles/2007/03/15/cover-me-im-going-in and when someone visits it, the controller gets a params hash which contains keys along the lines of: { :year => ‘2007’, :month => ‘03’, :mday => ‘15’, :permalink => ‘cover-me-im-going-in’, # the session, controller, etc } Which is okay as far as it goes[1], but it’s a complete pain when it comes to generating the url.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

DSLs, Fluent Interfaces, and how to tell the difference

I’m getting heartily fed up of people banging on about Domain Specific Languages. It seems that every time someone writes a Ruby library that uses class methods, symbols and hashes reasonably sensibly they get delusions of grandeur and call the result a Domain Specific Language (or maybe an ’embedded’ DSL). In a sense, they’re right, but it’s a pretty compromised language simply because you’re stuck with the Ruby parser. Scheme and Lisp hackers probably look at (say) ActiveRecord and sneer.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

The commenting problem

On Monday I went to the London Ruby Users’ Group March meeting. The theme of the meeting was code review, so I put up a chunk of code from my yet to be released Sudoku solver. It ended up being more like a talk because I spent most of the time trying to explain how Amb, the continuation based backend worked. At one point, someone noticed the lack of comments in the code and wondered if this was because I considered it self evident.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

D'oh! Why didn't that click before?

There’s a very cunning trick that most Smalltalk implementations use to avoid dereferencing pointers when they’re dealing with ‘small’ integers. And for years, I’ve misunderstood it. For some reason I used to think that Squeak say looked at the value of a pointer to an object and, if it was < some biggish number, it would be treated as an integer. Which is cunning, I suppose, but nowhere near as cunning as what really happens.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Listen to the Voice!

You know that voice at the back of your head that says things like “That’s not really a data structure, that’s an object that is!”? You should listen to it. I’ve been battling away with having a million and one things monkeying with a result set that consists of an array of arrays, when really it should have been a ResultSet which has a collection of ResultSet::Rows. Once I bit that bullet, I got to do things like add ActiveRecord::Errors to each row and generally start to bring a bunch of big guns to bear on a problem.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

For bad, map pretty

Adam Turoff is one of the good guys, a fine host who doesn’t mind when your wife pulls his shower tap off the wall, a wise programmer, mine of information, and an enlightening man to talk to. It was Adam who popped up in an iChat window not long after Rails got released and suggested I take a look. So, when he started up his Notes on Haskell techblog, I subscribed immediately.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Ah... found it

Almost every time I hear Rails people banging on about Little Languages[1], I find myself wondering what the fuss is all about - these things are not exactly new after all. Then, while I was rereading The Structure and Interpretation of Computer Programs for the nth time and realising how much I missed the first n-1 times through, I came across this: It is not exaggeration to regard this as the most fundamental idea in programming: The evaluator, which determines the meaning of expressions in a programming language is just another program.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Technical Entitlement

At RailsConf Europe this year, DHH went in quite strong on the idea that simply using an opensource framework, like, say, Rails didn’t entitle you to much of anything. The precise phrase used was, if memory serves “We don’t owe you shit.” Which is why I’m finding a certain irony in this, from the official Rails weblog: Versions [of SQLite] after 3.3.7 incompatibly changed the way in which default values are stored, making it so that current versions of Rails get into quoting issues and problems with columns with NULL defaults .

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

Initial release of acts_as_resource

Right. I’ve bundled acts_as_resource up and stuck it on the typosphere SVN server. You can grab it from http://svn.typosphere.org/typo/plugins/acts_as_resource if you’re interested. It’s currently in what I’d call an all convention, no configuration state - if your resources don’t look pretty similar to the kind of things you get from the resource scaffolding, you’ll probably have some pain, but I expect to rectify that with coming releases. One thing I want/need to do for instance is to allow for ‘relative’ ids in your resource url.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions

'acts_as_resource' progress

I’m very nearly ready to release acts_as_resource, I just have to pull up and tidy code that’s currently in my working directory’s ApplicationController and we’re laughing. However, I thought you’d like to see what my nested controller looks like.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions