Archive for February, 2008

Cometd and me

Friday, February 8th, 2008

I kind of go on tangents when I do personal projects. First my goal was to make a poker game for bots to play… then somehow it diverged to making an ajax client…. somehow it diverged after that to use comet/cometd to do it… and then finally I decided to rewrite the cometd-twisted for my own evil.

Basically, for games and such, the bayeux protocol is a good place to start, but all the publish/subscribe stuff is superfluous. I basically just wanted to use the heart of the protocol and the ability to use the existing JavaScript libraries.

I think what I did is pretty cool. Basically, I made it so when a client connects it spawns a new client class. Then when they subscribe to a channel it makes a ChannelSubscription class. The messages are routed through this. Each ChannelSubscription behaves as a logical connection to the client such as a Protocol class with Twisted would. In fact, there’s about 3 lines of difference between my TCP layer for my poker client and my comet layer now. It’s pretty cool.

I set it up so that authentication and such would happen one level on top of the Bayeux protocol to allow for more customizations. It doesn’t matter whether or not they connect.

I have half of an ajax poker client written for my server with this, but it’s basically just a proof of concept that this works. I think I’m going to write a blackjack server too to allow for easier testing, and a better demo for when there aren’t people to play against. It’s simpler, and I already have most of the code done in Ruby from a long time ago… I just need to port it over Python.

Anywho… I’m calling my cometd server ucommet. Why? I couldn’t think of anything better.

The source is here for all the stuff (you want ucommet.py and possibly tabled.tac to see how it’s used)

you can do a “svn co http://svn.lolrus.org/dpoker/trunk dpoker” to get my poker tree.

You’ll need twisted.web2. If you have twisted 2.5, actually might have to get the SVN version. The apt-get seemed to get a working version for me in Ubuntu, but on my Gentoo server it was a whole different story :(.

I’m going to be in Prague with some friends for the next three days (my last days in Europe before I come home). Then once I get back to the states, I’m going out to Cali for a day or two for an interview. It’s been too long since I’ve had a burrito or a double-double. So what this means is I probably won’t have time to work on this for the next week or two.

Better Keyword Search for Wikipedia in Firefox

Wednesday, February 6th, 2008

If you’re not aware of the “Add Keyword for this Search” try going to google and right-click on the search box, and click “Add Keyword for this Search” and just put a keyword as “test” for now. Now, hit ctrl+l (or cmd+l on a Mac) and enter “test election” and it will take you to a search page as if you searched google for “election.” Basically, you can do this with any search box. It’s really great, actually. I much prefer this method to the search box because I only like using one hotkey.

Anyways, since I frequent Wikipedia a lot, I have one set up for Wikipedia. Unfortunately, Wikipedia isn’t all that good at catching your typos or knowing where you really want to go like Google does.

Solution: Set up a quicksearch to use google’s are you feeling lucky to search wikipedia.org. Here’s how you do it:

  • Go to Bookmarks->Organize Bookmarks
  • Create new bookmark
  • Add a name and appropriate keyword (I chose “wiki” for mine)
  • For the location use:
    http://www.google.com/search?hl=en&q=site%3Awikipedia.org+%s&btnI=745

I found a nice little tip on what to add to the search to “feel lucky”.

dPoker Progress

Sunday, February 3rd, 2008

So most of my finals here are done.  I have a week before head out to Prague for a few days before flying back to the U.S.  I think I’m going to put on about 10 pounds the first week I am back because I miss all the delicious food.

This means I might get my dPoker server working.  I have a bit of the Twisted stuff in place.  I’m currently working on the gameflow logic right now and trying to engineer a good abstraction for it.  Right now I am just doing a TCP implementation, but since the whole protocol is in JSON it should be easy for me to make an HTTP thing for it too, and be able to hook up to JS.  I’m thinking perhaps a widget?  I’ll keep y’all posted.