chrishowie.com

Web

Gazebo: An AJAX interface to FICS

by Chris on Mar.23, 2009, under Chess, JavaScript, Web

I’ve been getting back into chess recently, and my favorite online community is the Free Internet Chess Server (FICS). There are a wealth of free and open interfaces available for download, but they all have one thing in common: you have to download them. At my workplace this is a no-no, but over my lunch break it would be nice to get in a few games. If I forget my laptop then I have no way to play.

Enter Gazebo. I started this project last Friday night, so it’s only been about two days. Still, what I have right now is rather impressive for that amount of time. At face value, the current version is not very representative of the time that’s gone into the project so far, and for a very good reason.

The HTTP protocol used by web servers was not engineered around the idea that you’d establish a long-lasting connection with the server. It’s better suited for quick request-response cycles. Because of this, the PHP web service has no good way to maintain a connection to FICS.

The solution I came up with for this problem is simple, yet very involved. A daemon script (yes, written in PHP…) listens on a UNIX socket for connections from the PHP web service script. If a new FICS session is requested, it creates a new session and returns some authentication parameters to the web service. On every request to the service, another connection to the daemon is made over the UNIX socket, the session attached to with the authentication parameters, and some action taken, like “write this to the network socket” or “tell me when you get new data from the network socket” or even “close the network socket and destroy the session.” The daemon essentially acts as a super-proxy that persists the network sockets and enables access to all of them from one UNIX socket.

Yes, it’s kinda ugly. But it also works incredibly well. There is still some tuning to be done, but behold the awesomeness of what is essentially in-browser, color-coded telnet:

Leave a Comment more...

Teh Rainbow Conspiraseez

by Chris on Sep.08, 2008, under Web

Saw this video in my reading list today.

I don’t know what they put in the water either, but I bet Obama can fix it with his amazing super change-bad-stuff powers!

5 Comments more...

The new Delicious!

by Chris on Aug.01, 2008, under Web

The new version of del.icio.us (complete with a domain name change) was released yesterdayish and looks a lot nicer. Oh, but wait. About two out of three page loads: “Sorry, you’ve been temporarily blocked for accessing Delicious too rapidly.”

Did Delicious hire the Twitter engineers, or what?

Leave a Comment more...

Three-column CSS layout

by Chris on Jul.07, 2008, under Computer, Web

There are many established CSS layouts for doing a three-column website. They seem to work pretty well. Perhaps the most popular is the Faux Columns technique.

At work we are working on an internal site that requires three columns (or to be more precise, up to two sidebars). I have never been completely satisfied with the many existing three-column hacks so I decided to roll my own after laying out some requirements:

  • The unstyled page should look decent (primarily for mobile browsers). This includes having the sidebars come after the main content in the HTML source.
  • The sidebar backgrounds should extend down to the header, without using any background image tricks.
  • IE7 and FF2+ must render the layout correctly. Minor defects are ok in other browsers.

The sidebar backgrounds have always been the tricky part, but I have a non-image solution for IE7 and FF2+. It also works in Safari.

IE6 does not extend the background colors to the footer, but it does correctly position the sidebars at least. After a bit of hackery anyway. Apparently IE6 doesn’t correctly compute the correct X position for absolutely-positioned elements. left:0px was making the left sidebar overlap with the content. I replaced this with float:left and IE6 positioned it like the other browsers, and thankfully the other browsers continued to position it in the same place. So as a bonus, no IE conditional comments were required.

Anyway, here it is. I am releasing the CSS and HTML source to the public domain, but if you reuse the code a link to this post would be appreciated.

1 Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact me so I can take care of it!

Links

Links to friends' blogs, and a few other sites of mine.