Topic “Programming”

Cromulac lives on in Python form

A long time ago I wrote a PHP app called “Cromulac” (A perfectly cromulent generator of random words) that chewed up /usr/share/dict/words and spit out plausible but usually fake words using Markov chains.

Last night I wanted to apply the same technique to a list of New England town names, but on digging up my old PHP code found it ugly and somewhat hard-coded with the dictionary file in mind, so I wrote a new implementation in Python and released it on github:

http://github.com/usonian/cromulac

It’s a more or less procedural script that’s pretty ugly itself, but it gets the job done; here are some imaginary New England towns you might like to visit:

  • Scrabansfield
  • Easton Point
  • Orlanton
  • Tapline
  • Tar Ridge
  • Aubury
  • Havens City
  • Orwellin
  • Coatuckett
  • Craffolk
  • Wesset
  • Atkinsville

I may or may not reorganize it as more of a module, so it can be used by other Python scripts too.

Drupal

I’ve finally started getting my hands dirty with Drupal over the last couple of weeks, going through the process of actually building a site versus adding a couple of pages and menu links here and there to see how it works, and now poking around under the hood to learn how to extend it.

Adding a bunch of pages in a row using the standard interface is usually a pain in any CMS, and Drupal is no exception: Click to expand all of the option fields, click through another screen to attach the new page to a menu, try and remember the weight of the last item you added, repeat.

Half the problem when trying to learn a new language or platform on your own is finding a practical application for it. You never get very far with “Hello, World”.

I’m really surprised there are no Drupal modules out there facilitating the import of existing content and/or menu structures. At least, none that I have been able to find other than the excellent WordPress Migration Utility . I used that to move the last 5 1/2 years’ worth of blog entries over to Drupal.

So, there’s my first practical application: a module that imports either a page hierarchy, creating a menu and stub Page nodes, or possibly even importing actual content.

I’m not sure what the import format will be. The smart way to develop this would be to make the import tool pluggable, so other people could write drivers to import whatever format they need. I think that’s overly ambitious for the first version of this plugin, but I’m beginning to get a sense of how that could be accomplished without too much trouble in Drupal.


31 January, 2009 It took me a while, but I did ultimately build just such a module. It’s in the Drupal contributions repository, and it’s called Bones.

HCI Niceties

One huge peeve of mine is the addition of JavaScript that uses the body onload event to trigger a focus() call to put the cursor into the login field.

I know it’s well intentioned, and probably works fine for all those fortunate enough to have broadband access.

If you’re stuck with dial-up, however, you often find yourself filling out a login form while you wait for the rest of the page to load. I can tell you from repeated experience that it is DAMN annoying to be halfway through entering your password, only to have your cursor picked up and dropped back in the username field.

Why not spruce up that ‘onload’ call to first check and see whether the the username field is empty? If yes, by all means focus on it. If no, assume somebody’s already filled it in.

24 Hours of Inform

My name now shows up on the third 24 Hours of Inform contestant list, so I had better get cracking.

Actually, the development time restriction and mandatory plot elements are quite helpful to me as a first time Inform author; I've zeroed in on an idea and all that remains now is to do some research and code the thing. (Oh, is that all there is to it! I make it sound so easy to myself.)

"The adventure must be set in a theatre. It must involve a petticoat, an advertisement, something which is repainted, and a trapdoor."

Famous Last Words...

I can't be the only person out there who just wants a single-user blog that they can host on their own boxen without wading through all the extra features that come with the portal-style systems.I'm hardly an authority on Weblogs, seeing as I seem to abandon every single one I try to set up or maintain after about 5 entries, but I think that's largely because I haven't been happy with any of the ones available at Sourceforge and other free software sites; systems like Slash and its PHP equivalent PHPNuke are fantastic, but way, way more than I need to run my pissant little waste of bandwidth. I don't need polls, or Slashboxes, or a message board, or 8 dozen pre-defined topics that I'll never use, or the bad, bloated HTML that always winds up in the predefined theme templates. Sure, they're heavily customizable, but to effectively design your own theme you have to learn a whole new API and chances are you'll have to use nasty, crufty HTML to make everything look right and align properly. For that matter, I don't need an extensive user registration or comment moderation system. If (God forbid) I should ever find myself getting enough traffic to warrant a comments and moderation system, I'd just as soon build it myself.

So it comes down to this: It's time to roll my own. I've made abortive attempts at this before, full of convoluted, poorly commented code that I can't even figure out myself six months later, but this time I'd like to approach it as a project that might be of use to somebody else... I can't be the only person out there who just wants a single-user blog that they can host on their own boxen without wading through all the extra features that come with the portal-style systems. It will need to be well-written, easily customizable, and extensible. It will defintely be written in PHP, and it will probably use MySQL for its database, as much as I'd like to use PostgreSQL. (mmmmmm, foreign keys.) Lots more people use MySQL, at least at the time of this writing.

I've learned quite a lot about programming style and programming in general since I started tinkering with PHP at Stan Lee Media, and I've used one hell of a lot of free (as in speech) software in the process. The nagging voice in the back of my mind that tells me I should give something back has been growing steadily, and since I haven't really learned C yet it looks like PHP will be the way I can do it.

Syndicate content
Syndicate content

Twitter

Older

Contact

Andy Chase
(978) 297-6402
andychase [at] gmail.com
GPG/PGP Public Key