KBD

Keith Devens .com

Tuesday, December 2, 2008 Flag waving
We ought always to deal justly, not only with those who are just to us, but likewise to those who... – Hierocles

Archive: May 24, 2004

← May 23, 2004May 25, 2004 →

Daily link icon Monday, May 24, 2004

E-mail correspondence chess

I'm starting a game of chess by e-mail, and I'm all excited. I want to use software that'll keep a history of the game for me and let me see the game so that I don't have to set up a physical board. It turns out there's a ton of software to do this.

I'll paste more when I find them. For now, I'm going to try ChessTool. Yikes (just installed it), the scrollbar flashes in the program. Weird Smiley Update: I'd recommend against ChessTool. Now trying MailChess. Update: Nah, too complicated. And neither so far has had an "undo" button. Using IceChess for now. But the board is too tiny and not resizeable.

Update: Here's a big list of chess programs I'm going to go through. I don't really like any of the programs specifically meant to do e-mail that I've tried. All I really want is a "viewer" program.

Update: Lots more links:

  • Jose - pretty awesome, and has a great 3D view. Update: the whole thing is kind of klunky, slow, and glichy, particularly the 3D view. Ah well. The 2D view is still good. I'll use it for now. Update: No, I won't. I can't get the computer to stop playing, so it's not good for correspondence chess.
  • XBoard and WinBoard
  • Arena
  • Skid
  • Knights (for KDE)

Here are a bunch more chess links. I should mention the Internet Chess Club here. I used to be a member a while ago, and it's a great service. Unfortunately, their Windows interface, Blitzin, doesn't let you use its features when not connected to the server.

Does Google treat periods as word separators?

Dog food

I'm not sure this is a fair test though, because the permalink will show up in the page text for the link URLs.

Clean URLs with mod_rewrite and PHP

What follows are the two main pieces of mod_rewrite that I ever use. I've posted these in separate places before, so this is mostly just to aggregate them in one place, as well as to explain how I make sure all URLs on my site are "clean".

First, these rules pass any request for a file that doesn't exist through the "dispatcher", a PHP script which can then do whatever it wants to. It serves as a Front controller (in that article's terminology, Apache acts as the "controller" while dispatcher.php acts as the "dispatcher"). Importantly, note that with the second line commented out, like I have it, this also bypasses directory handling (mod_dir) which means that any index.php, index.html, etc. will never be called. I prefer it this way mainly because I don't like mod_dir sticking trailing slashes on the end of any my URLs. I have a strict policy that no URL on my site can end with a slash (try appending a slash to a URL on my site, I dare you). The way I do it, no URLs have extensions (except images and things that I want to be served directly by Apache) so everything can look like a directory anyway.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dispatcher.php [L]

All of the mod_rewrite directives I list here I have in my .htaccess file in my document root. Note that the slash before dispatcher.php is important, as an analysis of mod_rewrite logs shows that while it would work without the leading slash, having the leading slash makes the translation take fewer steps (which is presumably more efficient).

The way I handle my content is that I have a special "content" directory outside of my document root and my dispatcher parses the URL and serves up what you want if it exists. This way I avoid cluttering up my document root. I don't personally use the following rewrite rules because of this, and because I serve things through the front controller rather than directly, but if you use the following rules, any .php file in your document root will be able to be served without an extension.

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule . %{REQUEST_FILENAME}.php [L]

Of course, this has to go before the above directives, otherwise it won't be run because dispatcher will get things first. To prevent the files from being accessed with the .php extension, you may want to implement some logic, possibly using auto_prepend_file, to do a permanent redirect from the .php version to the sans-.php version. Because the regular expressions in mod_rewrite don't support non-greedy matching, I don't think there's any way do that redirect in mod_rewrite itself, you need to use PHP for that. It can be as simple as something like:

<?php
if(substr($filename, -4) == '.php')
    
setHttpLocation(substr($filename,0,-4)); #take off the .php
?>

In fact, that's taken almost directly from my dispatcher. setHttpLocation() is straightforward -- leaving it in there makes it work as good pseudocode.

Then, to handle subdirectories in this scheme, you can use subdir.php to represent the subdirectory root (instead of having something like subdir/index.php), and then subdir/whatever.php to handle subdir/whatever).

The other way you can make clean URLs with PHP is by using the following directive in your .htaccess file:

DefaultType application/x-httpd-php

That will make any file not recognized by Apache, including files without extensions, be served as PHP, but this creates problems if you want to have subdirectories since you can't have a file and a directory with the same name.

Update (Jul 9, 04): Note that if you use the dispatcher.php mod_rewrite rules above, you should also add dispatcher.php to your DirectoryIndex setting.

Update (Jul 13, 04): Also see this. You'll probably want to change one of the above lines to "RewriteRule . %{REQUEST_FILENAME}.php%{PATH_INFO} [L]".

Quote about programming

These quotations pages have been floating around today. I noticed a quote by Dijkstra on the page of quotes about computer languages that really struck a chord with me:

If we wish to count lines of code, we should not regard them as lines produced but as lines spent.

← May 23, 2004May 25, 2004 →
December 2008
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 7 posts

Recent comments XML

new⇒Perl 6 1.0 in March?

Doh, my mistake. I'm aware of the​relation between Parrot and Rakudo​but I'...

Keith: Dec 2, 1:03am

Free image hosting sites

Well, TinyPic has this in its​FAQ:

> Images and videos is in​your accoun...

Keith: Dec 1, 1:13am

Join a NameValueCollection into a querystring in C#

Well with a lamba expression, this​is what I came up​with:

?!code:csharp...

Gustaf Lindqvist: Nov 30, 4:38pm

Why no generic OrderedDictionary?

Check​http://www.codeproject.com/KB/recip​es/GenericOrderedDictionary.aspx?d...

Gabrielk: Nov 27, 6:57am

WhatIsMyIP.com

http://www.thesysteminfo.com is​another good alternate to​whatismp.com... I...

Kripz: Nov 26, 8:51pm

Girls, please don't get breast implants

Actually I think it's sweet when a​man loves a woman whether she's big​or n...

218.186.12.228: Nov 26, 9:40am

Generated in about 0.08s.

(Used 7 db queries)

mobile phone