Posts tagged: PROGRAMMING

Evolving a new keyboard

This is amateur science at its best. Peter Klausler, an aficionado of the Dvorak keyboard layout, decided to see if there were better permutations of keys yet unrealized:

…I constructed a complicated function that measures the amount of “work” needed to touch-type a given text with a given layout.

Very good. But where does the primordial soup of keyboard layouts come from?

…4096 keyboard layouts compete with each other. The layouts in the initial pool are entirely random. In each generation, they all race to “type” a word list, and their per-word times are multiplied by the word frequencies in the input sample. After the race, the fastest half are kept. The pool is then repopulated by generating a single mutation for each survivor.

You really should learn regular expressions

Here’s another advice post. Luckily, many of you can test out of it, like a college Gen Ed requirement. Here’s the test:

  1. What does the following regular expression do? ^http[s]?://([a-z]+\.)?example\.com/$ (Answer below.)

The target audience for this post is people who have heard of regular expressions, but don’t use them. Or who have used them a little, but have the feeling they really should know them better.

You’re right. You should.

Quick, but not dirty, PHP

Though I’m doing more and more work in Python, I still write a lot of PHP code, especially for quick one-off web automation tasks.

There is plenty of activity on the other end of the scale in the PHP world now: frameworks like Cake, WASP, Solar, TaniPHP, the forthcoming Zend Framework. All this action is very cool, but doesn’t address the one-page script – and the one-page script is still worth doing right.

Many people come into PHP helter-skelter, not realizing that “Wow, it works!” is not the highest level of achievement possible. I don’t offer myself as a PHP guru, but below are some of the conventions (I dare not call them “patterns”) I use that I think are worth passing along.

BASIC Computer Games

BASIC Computer Games

In 1981, I was 13 years old and teaching myself BASIC on my TRS-80 Model III from official Radio Shack manuals – accurate, comprehensive, and terminally bland.

Into that gray scene came the book Basic Computer Games: Microcomputer Edition (edited by David Ahl of Creative Computing magazine). It changed my life.

I can’t remember now where it came from. Neither my parents, nor my friends, nor my teachers knew much about the home computer scene. It’s possible that I found out about it in Creative Computing magazine and ordered it by mail, or “borrowed” it from somewhere and forgot to return it. The book, subtitled “101 great games to play on your home computer,” was 8-bit-nerd heaven. Pages and pages of program listings in tiny, all-caps, dot matrix type, with brief introductory paragraphs. Plus, funny illustrations of strangely plausible robots. Don’t underestimate the appeal of the robots.

Big Nerd Ruby Ranch

Big Nerd Ranch, which became well known on the strengths of Aaron Hillegass’s Cocoa training and writing, has a new offering in their “bootcamp” series: Ruby on Rails Bootcamp. It’s taught by Marcel Molina Jr., a longtime Rails contributor. Most of the stuff Big Nerd Ranch teaches has been around in one form or another for ten years or more; it says something that they are tackling something so relatively new. Another jump in mindshare for Rails.