PHP contest: Texas Holdem

I thought this sounded interesting considering how popular poker is these days (you know who you are): PHP Editors is holding a PHP programming contest for a Texas Holdem game. I might try it out. It wouldn’t be anything like most commercial poker sites out there, but it would be an interesting programming project.

…Not unlike being back in school, writing a program for whatever computer course I’d be in. Those were the days; they were still teaching Pascal at the time. I remember writing a Hangman game (it mostly sucked), and an algorithm for storing shuffling a deck of cards (which might have been a precursor for a poker program).

Of course, handling and “shuffling” a deck of cards that only exists in a computer program is trivial. You simply need to have a structure representing the cards, and draw them randomly. (And a method for keeping track of what’s been drawn.) Each subsequent “shuffle” is simply a different random number set selecting the cards.

I’m no longer cutting edge on PHP

I just realized this; I haven’t used PHP 5 at all since it came out, so I’m terribly illiterate about this latest version of PHP. I still use PHP 4. That means I’m no longer cutting edge on PHP! Or maybe that just means I’m no longer bleeding edge, since PHP 5 adoption has been terribly slow.

Maybe it’s a good time to learn COBOL

Two interesting factoids from ADTmag’s 2005 Salary Survey:

[Application Programmers] Programmers in mainframe and Unix shops make the most, topping $59,000 a year in base salary. By development language environment, programmers in CICS and COBOL shops fare best, drawing average salaries of almost $62,000 for CICS-based development and $59,000 for COBOL.

[System Programmers] Mainframe skills continue to be a strong suit for systems programmers, who earn an average of $71,100, outpacing their Unix counterparts by about $2,000. By development language environment, systems programmers in CICS and COBOL shops fare best, drawing average salaries of $72,100 and $70,200, respectively.

$59K to $70K per year for being a COBOL programmer? Whoa.

Oddly, it ties into my COBOL note from almost exactly a year ago.


Just for grins, and to flex my PHP chops, I decided to write a simple wiki system. The catch, though, is to see how short I can make the actual program; I was inspired by this Shortest Wiki Contest, though I can’t profess to be quite as fanatic as those guys (I prefer readable code—squishing it all into a minimal number of obfuscated lines just seems like cheating), I think I did pretty well so far. Read through if you’re interested; it’s pretty technical and I include the PHP source.

Continue reading “BittyWiki”

20 questions

Okay, so I must be easily impressed. From this post on Boing Boing I found the site and began trying to stump the system. I can’t do it. No wonder; the guy that created the neural net (a type of artificial intelligence software) started it back in 1988, and it’s been “learning” ever since, entirely by people playing 20 questions with it. Crazy.

I remember having a 20 questions “A.I.” game that came with the Logo programming language for the Commodore 64 (way back in the day). Same deal, it was preprogrammed with maybe three items, but as you played it, it remembered every new item you fed it and got “smarter” each time it played. The only drawback was that on a Commodore, you couldn’t really save the state of the program, so it would “forget” everything each time you started it up.

Funny part is, I remember the first time I played it, I figured I’d stump it with “ostrich.” I just about fell out of the chair when, after about five questions, it says, “Are you thinking of an ostrich?” I was hooked, but ultimately didn’t fully capitalize on that for another few years… at the time, I simply considered it to be an exotic toy. Now I write software for a living. Go figure.


Jeff Sandquist has a pointer to a video interview with two programmers that are writing a PHP compiler for Microsoft’s .NET Framework. The name of their project is Phalanger.

That’s cool, I guess, if you don’t mind working in .NET. I’ve been thinking for awhile that I wouldn’t mind a PHP compiler that would create standalone executables (though cross-platform, not just tied to Windows), so this is kind of a step in that direction.

Of course, there’s already PHP-GTK which is cross-platform. And hmmm, I notice in their February news, there’s a pointer to a project called bcompiler which lets you create an exe file from a PHP-GTK app… very interesting.

Oops, and I notice the Roadsend PHP compiler does just what I was rhapsodizing about. It appears I’m behind the times. Though the “Professional” edition (compiles to Windows, Linux and FreeBSD) costs $399 (“Personal”—Windows only—is $89).

Amazon Links

Astute readers will notice that I now have Amazon related links (books, actually) on some entries (spun out of my Amazon’s Web Services post). Hopefully they’re not too intrusive; I have them limited to a max of three results right now, and they’ll only show up on blog entries that I specifically keyword.

All done with Amazon’s web services. It’s not completely automatic, since I have to keyword the entry, but it beats looking up items by hand. Using the web service interface is extremely easy; simply build a URL and send the request to Amazon, and you’ll get XML results. I’m using the excellent Snoopy PHP class for the communication piece, and PHP’s built in XML parsing (using expat) to extract the information I want from the XML.

Some tips, after trial-and-error: Use a “Power” search in the Amazon request, especially if you have multiple keyword sets. An example might look like:

Power=keywords:(web services) or (xml) or (http programming)

The regular “Keyword” search turns useless after four or five words, it seems, and the “TextStream” search returned totally random results.

I played around with have the results sorted by rating (“reviewrank”), but dropped this because I was finding that older editions of the same book (hardcover vs. paperback, for example) might have a higher rating, but not actually be available. By dropping the sorting entirely, Amazon returns surprisingly relevant results.

The results can include images, all hosted on Amazon’s servers. Use them! They come in three sizes.

And finally, pick your keywords carefully. Or you’ll get some weird, totally unrelated items.