Archive for January, 2008

simplejson vs. python-cjson

Friday, January 25th, 2008

I needed a package that decodes JSON into dictionaries/lists etc.  I’ve used simplejson in the past and it’s worked fairly well.  I came across another package today that claims to be at least a hundred times faster than the other JSON implementations for python called cjson.  I was a bit skeptical because simplejson has C extensions too.

I decided to run some quick benchmarks.  The code I ran can be found here.

benchmark data:
processor: Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
x86_64 Linux.
simplejson 1.7.3 (I assume the c extensions are enabled because I used emerge to get it)
python-cjson 1.0.5
Python 2.5.1

simplejson results:
% time ./simplejsonbench.py
./simplejsonbench.py 38.97s user 0.00s system 99% cpu 38.968 total
% time ./simplejsonbench.py
./simplejsonbench.py 39.17s user 0.01s system 99% cpu 39.187 total

cjson results:
% time ./cjsonbenchmark.py
./cjsonbenchmark.py 0.77s user 0.01s system 99% cpu 0.784 total
% time ./cjsonbenchmark.py
./cjsonbenchmark.py 0.77s user 0.03s system 100% cpu 0.794 total

simplejson average: 39.07s
cjson average: 0.77s

verdict: cjson 50.74x faster in this benchmark

I’d run more, but I don’t really think I have to. Simplejson actually seems to have a more robust interface than cjson, and is more portable because it doesn’t require a C compiler.

The cjson website has some other numbers that measure actual measured throughput of cjson vs. simplejson. The versions of simplejson is older, and it states there’s no C extensions compiled in.

Website Stats

Friday, January 25th, 2008

My blog gets very little traffic.  Actually, about 60% of it is people searching for the word “lolrus”, coming here, and being quickly disappointed then leaving right away.  I’ve been using awstats for a long time now, and recently just tried Google Analytics.  Google Analytics is soooo much more intuitive to use than awstats.  It also seems to have less noise in the data.  For example, /wp-admin is shown as one of the top things visited in awstats.  I don’t really care how many times I visit /wp-admin.  Google Analytics filters that out.  It’s interface is pretty slick too.

Aside from that, the job hunt continues.  Have a phone interview tomorrow.  I’m hoping to find a job before spring quarter starts so I can concentrate on my studies and finish on a good note.  It’s going to be a rough quarter.  I’m pretty psyched though because I’m probably doing an independent study implementing the iCAM image appearance model in Quartz Composer.

New Project: dPoker

Thursday, January 24th, 2008

I started a new project a few days ago. It’s one I’ve been pondering over for a long time, and it’s about time I did something about it. I’m bad at naming projects, so I chose dPoker, the d is for donkey.  Donkeys are cool either in poker, on waffles, or on waffles on VT200s in Sysprog class. Basically, the core of the project is just a poker server. It’s purpose is for bots to play, compete, and learn, not really humans. Of course, humans will be able to play too, once somebody writes a client. I have a few friends interested in working on this too, but I need to get a proof of concept together first.

I set up a trac for it here.

Here’s a few technologies I’ll be using and design decisions (for the proof of concept at least) and why:

  • The server will be written in Python.
    • it’s relatively fast and small in memory (compared to Ruby)
    • good libraries
    • readable
    • native thread support
    • I find it fun to write
  • Probably using Twisted framework.
    • It seems nice and supports a variety of protocols.
    • Eventually want to make a javascript client
    • Don’t want to reinvent the wheel
  • SQLAlchemy for data logging and account
    • I really like it
    • Sadly, there’s no recent updates to Asynchronous wrappers for for like a year, so I will probably have to roll my own :(.

I’ll be using a very simple protocol so people can easily write their own clients/bots in any language.  I’m trying to design it to scale well over multiple processes and servers.  It will also be modular so it can extend to different card games or non-card games.  The primary reason i want it to be scalable is because if computer learning is to be done, it has to either go really fast, or support hundreds of games at once.  There’s latency over the internet, so that would be the bottleneck for how fast a game finishes.  So my solution for networked games would be to have say maybe 10-100 instances of a bot running in that many different game rooms.  Although, there would still be latency, it would still increase the game’s played/time period.

Me or a friend will write a JS or even a flash client  so people can easily play over the internet against bots or each other.  I’d still have to work out a way to get people to try instead of going all-in all the time, but I think this would be important to add a bit of supervised learning to the mix and see how these bots evolve.

iPhone Native SMS Archiver

Sunday, January 20th, 2008

A while ago I mentioned going to BarCampBerlin. While I was there I met the creators of a website, Treasuremytext. They provide a service for people to archive their SMS’s to the website and then share them if they desire. Typically, one would forward their SMSs to a number, and then they would appear on the site. Unfortunately, there is no forward capability on the iPhone. So, they were interested in me writing a native application to archive the SMSs over the internet from the iPhone.

And that’s what I did. It was actually an interesting process. Treasuremytext didn’t have an API set up at the time, so I wrote a REST api with authentication, tokens, and keys to the one Flickr uses. I did this in my sandbox web application that I use in Pylons. To communicate with it, I used code from MobilePushr because it was already proven and GPLed. The author of MobilePushr, Chris, was very helpful in resolving some issues that I had (they were my fault though).

So after that, I spent a few days over my holiday working with the owners of Treasuremytext helping them set up their API and ironing out a few last issues with my app.

The source is GPLed. Feel free to use it. You can find the source and install instructions here. Also, if you find bugs or have feature requests, post an issue there. I don’t really SMS more than a couple times a month, so I won’t be doing too much testing.

Here’s some screen shots (click for full view):

iPhone screen 1

iPhone screen 3

And working on an archive/delete all feature that will be released once I figure out why NSThread is blocking my main thread:
iPhone screen 2

Food and Beer in Germany, San Jose, and Rochester

Monday, January 14th, 2008

As some of you might know, I’ve been in Osnabrück, Germany since the beginning of October. Well, one of the biggest joys in life to me is food. I wouldn’t be able to live in a place my whole life in a place that had bad eats.

Basically, right now I am sick of most food they have here to offer. Here’s a list of what I liked and am now sick of, should have liked, or too po’ for.

So, for Germany:

  • Döner Kebab - Alright, so this is one of the few foods I can still tolerate more than once a week. It has been my replacement for the burrito when I was in California, which was then my replacement for the Garbage Plate when I was in Rochester. Basically, it’s meat in a pita for 3 euros. You even have a choice between Lamb meat and Chicken meat. What else could I wish for? Cheap, warm, and scrumptious. I’m getting kind of sick of it now, but when I am hungry and/or a wee bit tipsy, there’s nothing else.
  • Pizza - In Germany it’s pretty weak… compared to what I’m used to at least. The cheese is pretty good, but it’s just not the same, sadly. Also they use salami instead of pepperoni. Not much a loss, but just different. You generally buy whole, smaller pizzas in Germany, usually at a Turkish owned restaurant as well, that most likely sells Döner too. You can even get a pizza with döner meat at some places. It’s pretty tasty, but just not the same as a nice New York style slice of pizza. Usually between 3 and 5 euros for a pizza that will even fill me up.
  • Brotwurst - Quite delicious compared to hot dogs. Comes in a Brötchen (a little roll, also called Semmeln in Bavaria). Too greasy for me now. I also don’t find them that filling either. Usually about 1.70-2.00 euros. At festivals you can get comically large ones. I’ve seen meter long ones at Oktoberfest, and half meter ones in Berlin for new years eve.
  • Potatoes - Pretty decent. Come prepared a few different ways. The boiled ones are pretty bland I think though.
  • Schnitzel - Only had a few time. Not bad, but a bit greasy to eat regularly.
  • Fish - Had some good fish, had some bad fish. The salmon is generally fresh.
  • Chinese Food - A bit disappointing. Not the type of dishes I am used to. They mostly have just noodle dishes or fried meat with a crust on sauce dishes. And curry. It’s more indonesian cuisine. I know what is “Chinese” food in the U.S. isn’t traditional, but that doesn’t mean General Tsao’s chicken isn’t 100% delicious.
  • What I make - Lately I’ve been adventurous. I’ve made some Thai Curry, some Sushi (surprisingly good), Ramen, potatoes. For a while I was making Brotwurst, but got sick of it. Also, I’ve made some not too bad steaks and fish.
  • The Bier - German beer is good. I’ve only had one or two bad beers. Most people drink Becks which is pretty good. The other common ones where I am are Warsteiner, Herforder, etc. You don’t get a lot of the good Bavarian German beers, or the Belgian beers that I love so much (will elaborate more later). You really have two choices. Weizen (wheat) beer, pilsners, or dunkels (which nobody except old people really enjoy). It gets a bit boring. I found a place about 2 km away from me which has Augustiner which is pretty much one of my favorite German beers. Justin and I hauled a carton which had about 10 liters back the other day and I was a bit sore after. We get Budweiser (the Czech one) here which is really good actually. I’ve been drinking that because it’s not a Pilsner and I am just tired of Pilsners. In Berlin there’s also Berliner Pils, and Berliner Kindl which I think is also a Pilsner. Boring. Beer at bars and clubs are usually between 1.50 euros to 3.00 euros for a half liter or .33 liter.

So I will go cronologically now. Here’s the highlights and lowlights of when I was living in San Jose:

  • In-N-Out Burger - Amazing! My friends in the bay had always talked about how delicious it was. When I crossed the border into Cali for the first time, when I saw an In-N-Out Burger, I immediately got off the highway. Needless to say, I was far from disappointed. Double-Doubles with grilled onions only are pretty much the best fast food burger I have ever had in my honest opinion. Everything at In-N-Out is fresh, and delicious, from the burger patties, to the freshly cut fries, to the lightly toasted buns. Not bad shakes either.
  • Burritos- Absolutely delicious. I like mine with carnitas, black beans, and light on the salsa. The best are most definitely in the Mission District in San Francisco. As far as local to where I was in San Jose, La Victoria’s Taqueria was pretty good, along with some other places. Haven’t experience burritos anything like it elsewhere. A regular burrito generally runs between $4 and $5. Not bad I believe!
  • Mongolian BBQ - Also one of my more favorite meals. Su’s Mongolian BBQ was the best. So good. All you can eat. Under 10 dollars. You make a couple bowls, the spicier the better because you know there’s a soft serve machine waiting for you after you packed the last bowl into your belly. I like lots of garlic, chili, and chili oil. King’s Mongolian BBQ wasn’t so bad either, but it was always empty and had not the best vibe.
  • Pizza - The only good pizza I ever had in San Jose was Amici’s. It was hella expensive though. Over $20 for a large that wasn’t even that large or something obscene like that. It was super good though. There was a decent Chicago style pizza place, but I don’t dig the deep dish. I had a couple pretty good slices in North Beach in SF. They weren’t too pricey either.
  • Korean - Had a few times, pretty good.
  • Vietnamese - I had it once, but didn’t really dig it. Maybe I will try again someday.
  • Thai - Pretty good. I discovered my love for red, green, and panang curry in SJ. There’s some cheap eats too.
  • Jamba Juice - Excellent smoothies. So good. Had a Jamba Juice for lunch sometimes, or for dinner.
  • Italian food in North Beach in SF - Amazing. I went to a couple nice places with Marisa. Really good. Once we ended up at this really kitschy place because all the other restaurants were packed. We were really skeptical, but it turned out to be excellent food nevertheless. The seafood is out of this world.
  • The Beer - Ehh it was mediocre. BevMo had a moderate selection, but it was really pricey and far out of the way. I usually stuck to Heinekin (FYI, Heinekin tastes WAY better in the Netherlands. Not a hint of skunkiness). Bars were really expensive. Even the dives. The cheapest beer in a bar around was $2 Pabst Blue Ribbons. Gag.

Now time for the Rochester portion. It’s been a year since I’ve been there, so bear with me if things have changed. I actually miss the food in Rochester a lot. It’s good and cheap.

I mention “plates” a lot here and they refer to garbage plates.

  • California Rollin’ - My favorite Sushi place. It’s usually super good. I’ve had a not-so-good roll or two there in the past, but when you go every week, there has to bee some off days. $12 for 3 roll Sundays is the best. It’s right in the Village Gate mall, so you can go get some records or piercings then get some sushi. How fun is that? Tuscany roll and Rainbow rolls are my favorites. Louisiana roll is pretty good. I also like the eel rolls, but I forget their names.
  • Piatzas - I was living on University Ave for 6 months. Piatzas is so good. HUGE slices for like $1.50. Usually really good. Nice thin crust. It’s like a little shack on Park Ave and Oxford intersection. Probably not the best pizza, but some of the best.
  • KC Tea and Noodle - This was closed for a couple months then reopened before I left. It has the only bubble tea that I know of in Rochester. They also have super good noodles! It’s a fun place to go and will make you feel good and happy inside.
  • Dogtown Hots - It’s only been around for a year or so now. Even if you don’t like hot dogs it’s worth checking out. Their hotdogs are amazing. They put them on buttered french bread instead of rolls and there’s 20 or so different toppings you can get. I also had a plate there once, and you can get onion rings on it. One of my favorite places. The people that work there are really nice. They also have vegi dogs, chili, and plates incase you’re a vegetarian or have one as a boy/girlfriend.
  • Mark’s Texas Hots - Open 24-7. Some of the craziest stuff that I’ve seen in Rochester has happened to me here, such as a girl passing out from alcohol poisoning and her friends fighting over who’s fault it is instead of helping her or calling 911. Once some guy sat next to me and a group of friends and told us how he once blew the kneecaps off a guy and said he’s lucky we weren’t lizard people. As far as the food goes, it’s pretty damn good. I prefer plates from other places, but their omelettes are top notch. If you can get there for breakfast they also have really good egg sandwiches. Really good service and nice waitresses. Sometimes you even get the honor of seeing Mark kick rude guests out.
  • Henrietta Hots - Honestly, a lot of people give this place crap, but I think they have the best plates. They use nutmeg or cinnamon in their hot sauce to make it taste oh so good. I go back there even though some friends and I got food poisoning there once. It’s closer to RIT than Mark’s or Nick’s.
  • Ming’s - Favorite chinese restaurant ever. It’s a hole in the wall place on Clinton Ave (I think). Justin introduced me to it. Since then I can’t get enough. Amazing General Tsao’s, dumplings, spring rolls. Good lunch special too. If you eat there you will smell a bit greasy after, but it’s worth it. They kind of deliver to some areas too.
  • Dibellas - Really good subs. Personally, I enjoy their hot roast beef or steak and cheese subs.
  • Old Toad - Pretty good British style pub. Good selection of beers. Free meal on your birthday. People speak with a British accent too.
  • MacGreggors - Right near RIT. Cheap specials. Huge beer menu. Definitely a mix crowd goes there.
  • Wegmans - There’s nothing like it anywhere I’ve been. They have a great selection of food, open 24-7, and treat their employees well.
  • Beers of the World - This is a specialty beer store. They have an amazing selection of beer from Treppist beer to African beer. I’m probably going to buy some brewing equipment from there when I get back to the U.S.

Anyways, I think I am going to call it a night. I plan on taking a trip to Belgium (either Gent or Brugges) before I leave, as well as Prague, and I will be sure to fill in the details of their beer, as well as some Dutch beer too.

[Edit: added some places I missed]