Tuesday, August 19, 2008

Yu Go Club

I've started a new blog for the Go club here in Pasadena, the Yu Go Club. You can find it here: Yu Go Club Blog In particular, I want to start writing about the future of Human-Computer Go. You can find my first article on the subject here.

Tuesday, July 15, 2008

Advice to a fellow developer

Here's my advice to a fellow Java developer who asked me how to learn Ruby on Rails. Having gone 100% Ruby on Rails since October of last year, I had a lot to say:
Join a local Ruby group if you can find one in your area. I would say definitely get the newest version of the Rails book, but wait a month or two if a new version is about to come out. Older versions aren't useless, but things change every day. Even the newest book will be missing things before ink even touches paper. I highly recommend Rails for Java Developers as the fastest way for you to get up to speed. After slogging through the Ruby and Rails books, I found RfJD wished I had read it first. They build on what you know from Java instead of starting you from ground zero, and that will save you a lot of time. Build a couple of VERY SMALL projects first before you launch yourself on a big project. Your first few projects will be very messy and hard to maintain, despite your best intentions to the contrary. Practice Ruby with simple problems like the ones at Project Euler. Ask a lot of questions. Shun the Rails Wiki pages. The information there is generally a mix of wrong AND out of date. Watch Railscasts videos. Suffer gracefully. Ask more questions.
Got any more advice to share? Post it here!

Wednesday, July 2, 2008

BookMooch vs. PaperbackSwap (Part 1 of 2)

I've been using BookMooch to trade books with people, and it's generally worked pretty well for me. However, I found myself ultimately with a number of points and a big wishlist of books that I wanted that nobody offered. Enter PaperbackSwap. I've been a member for about a week now. What do I think about it? I think they got a bunch of stuff right that BookMooch hasn't. Take a minor example: That's a referral banner that I can include in my blog post. I get points if you sign up through it. If you find this post at all helpful, I hope you'll use that banner to sign up for PaperbackSwap. What's the difference, you're asking? The most compelling reason for me is that they have a bigger catalog than BookMooch. Checking out the "Under the Hood" link earlier today, I found that they have around 4 books posted every minute. Right now the site says 2,280,827 books available. One of the most striking differences, to me, is the fact that BookMooch only gives you 2 points to start with (meaning you can request 2 books), and after that you can only ship books to other members or buy points, as a means of getting more points to request books. BookMooch, on the other hand, awards 0.1 points for every book posted and 0.1 points for every book you receive and provide feedback on. This means that BM is creating points constantly regardless of whether you're posting useful books into the system or not. More points received than spent means that it's easy to mooch books, and you don't even have to post books that anybody wants.

Thursday, May 8, 2008

Surprising findings using Ruby Arrays as Queues

I'm working on an Aho-Corasick implementation in Ruby, and found something interesting about Ruby. Well, something interesting to a relative newbie, I suppose... Arrays are the Ruby object that people use for Queues in Ruby. Which is a little odd, because the performance of Ruby arrays as queues is pretty poor. Worse, in fact, than inserts into a Hash. This is probably due to the fact that pushing objects into an array requires growing the array. Furthermore, I found that the performance of Array#+ is better than Array#push and Array#<<, even though all three methods ostensibly do the same thing. It turns out that Ruby does have a Queue object that performs well. It's intended for producer/consumer operations across multiple threads, but nonetheless it performs much better as a Queue than arrays do. Here it is, the Queue class in all its glory.

Sunday, April 27, 2008

2008 Presidential Election Poll

I've created a 2008 Presidential Election Poll using my Range Voting poll that I wrote about earlier. The polling application is ready for general use, although I do have a few more features I want to add to it. In the meantime, cast your vote for president!

Sunday, April 20, 2008

Range Voting Application

I'm happy to announce my new Range Voting Application, which allows you to set up your own range voting polls. After finding that Approval Voting didn't give my co-workers at the LA Times enough expressiveness, I started looking for a Range Voting system I could use for my weekly polls. When I didn't find a great Range Voting application, I decided to create my own. It's easy to use, both for voters, and for poll administrators. Try it out by voting in one of the example polls on the home page or jump right in by creating your own poll today! If you want to learn more about Range Voting, the folks over at RangeVoting.org have a fantastic site with lots of great information about Range Voting.

Sunday, March 23, 2008


After several attempts to get Google to index my server at home on my DSL (using a dyndns.org hostname, of course), I decided I needed to set up a more "legitimate" host. So, I bought a VPS instance at BuyAVPS.com for $9.99 a month so I could mess around with my own Ruby on Rails apps.

I tried to use some of the pointers I got from The Principles of Beautiful Web Design, which I finished reading last week, and ended up with a logo and welcome page that I can actually be proud of! Ok, so it's not much, but now I have a home for StampCalculator so people can actually discover and use it.

Thursday, March 6, 2008

Werewolf: Kill the quiet people!

Well, today I had the opportunity to be the storyteller in a game of Werewolf at our L.A. Times gaming lunch. Having played as a werewolf in the last three games in a row, I figured the villagers were going to kill me in the first round anyway, so why not be the moderator and break my streak? Today, we went down to two werewolves, after three werewolves have won every one of the last 4 games, with 10-14 players total. I'm promoting a handicapping strategy similar to what we use in Go. Basically, the villagers are trying to handle as many werewolves as possible. So, if one side wins 3 games in a row, you increase or decrease the number of werewolves by 1. As the moderator, I got to immediately see what role each player had, from the very beginning. So I got to see the seer accuse the one person she knew was a villager in the first round! I thought this was a clever ruse at the time, but in hindsight, the only person she fooled by this was a villager. Oh, well. I guess that's my "werewolf logic" showing through! Anyway, to the point: The villagers lost again. However, if they had stuck to the rule of "kill the quiet people first", they would have won. Why? The werewolves were quiet. Now, pay attention because I think this next bit is the thing people haven't been getting: If you have a policy of "kill the quiet people", you force the werewolves to participate! Werewolves are liars, and when you're a liar, you don't want to draw attention to yourself. So if the villagers show that they're intent on killing quiet people, the werewolves have no choice but to participate in the conversation. By smoking them out in this fashion (and not letting quiet people off because "we don't think that person is really a werewolf"), you force the werewolves to participate, and you might catch them in a lie. Update: I remembered what's so clever about the seer accusing an innocent person. It fools the werewolves, who are looking to kill the seer as quickly as possible. Bonus points if the seer gets a quiet person in this fashion, because that helps to flush out the wolves. While they're off the scent of the seer, the seer can continue to gather data about everybody.

Monday, March 3, 2008

Improbable Truths in Ruby

The following statements are all true in Ruby 1.8.6: 0.6 - 0.5 < 0.1 (0.29 * 100).to_i == 28 0.28 * 100 != 28 (0.28 * 100).to_i == 28 (0.27 * 100) == 27 Well, what can I say? Floating point errors in Ruby can really bite you. I had always thought higher precision numbers were necessary only when dealing with very small numbers or when computing compound interest, but look out! Ruby floating point can really bite you with some strange, unexpected results. It makes me wonder why Matz included a to_i method at all!

Saturday, March 1, 2008

Weird Floating Point Problem in Ruby

I'm working on a simple postage stamp calculator, just one of several projects I have for some Ruby on Rails practice. So I set up my rspec tests and find that one of my tests is failing. After stepping through the test, I found something that I find very surprising: 0.5 - 0.4 < 0.1: irb(main):001:0> 0.5-0.4 => 0.1 irb(main):002:0> 0.5-0.4<0.1 => true irb(main):003:0> ((0.5-0.4)*10) => 1.0 irb(main):004:0> ((0.5-0.4)*10).to_i => 0 irb(main):005:0> ((0.5-0.4)*20).to_i => 1 irb(main):006:0> ((0.5-0.4)*20) => 2.0 ...well, this certainly violates the principle of least astonishment, but I guess the lesson is that I should be using values in terms of pennies (ie, integers not floats).

Sunday, February 24, 2008

Misconceptions about diet and exercise

Most people I talk to about losing weight have two misconceptions about getting and keeping their weight under control:
  1. "Going on a diet" is a good way to lose weight.
  2. If only I could exercise more, I could lose weight.
"Going on a diet" is a bad way to lose weight. Why? Because of the tacit understanding that the diet is something you would never willingly follow for the rest of your life, some day you're already planning up-front to go off the diet. What's going to happen then? You'll eventually be right back where you were before you went on the diet. As for exercise...well, we all know we should be exercising, but that doesn't mean we always have time to exercise. In fact, many of my overweight friends are just waiting for themselves to have time to exercise. Let's face it. Sometimes you'll have time to exercise, and sometimes you won't. There is no need to wait for yourself to have time to exercise. You can change the way you eat and lose weight without exercising. On the other hand, you could start exercising today, eat more, and not lose a pound. Diet and exercise are two different things that are very important to your overall health, but exercising while ignoring your eating habits is self-defeating: When you don't have time to exercise, you'll start gaining back whatever weight you lost. I submit that the only way to lose weight is to take in fewer calories than you burn. So, if your weight is relatively stable, then all you have to do is be consistent about eating a little bit less at every meal, and with no changes at all to your exercise, you'll stabilize at a lower weight than you have today.

Why the French aren't as fat as Americans

Found this today...researchers are supporting what I've been telling people for a while: Cleaning your plate will make you fat! Actually, the article says something more interesting than that: it says that the French rely on internal cues such as feeling hungry and feeling full, while Americans rely on external cues like whether the plate is empty, whether they have remaining beverage, and whether the TV show is over. Furthermore, they say there's a correlation in both populations between relying on external cues and being overweight:
"Furthermore, we have found that the heavier a person is -- French or American -- the more they rely on external cues to tell them to stop eating and the less they rely on whether they felt full."
What does this have to LYSBYG? Everything! Your stomach tells you when to eat, and it tells you when to stop eating. In order to lose weight, you first need to start heeding your stomach. Stop eating immediately when you feel full. The second step is to consistently eat a little bit less, and drink a little bit less at meals, and your stomach will adapt itself to a lower intake level if you're consistent about it.

Saturday, February 23, 2008

Go Club finally taking off at the Pasadena Central Library

For a couple of years now, I've been coordinating a Go program at the Pasadena Central Library. It's been tough, with many weeks having only 1 or 2 kids in attendance and others with no kids at all. I've lost a couple of my original volunteers, and I'm always on the lookout for more. At this point I have only two others and myself to cover the weekly Saturday sessions. Back in December, though, attendance started to pick up, and this Saturday I had 11 kids, one parent, and one adult who dropped in to learn the rules. This is very exciting! It proves my theory that you need 4-5 people weekly in order for new people to come to your club and decide to stick around, but more importantly, it means that we finally have a real club at the Pasadena Central Library. We meet every Saturday from 2-4 pm in the Teen Central room. You should come by sometime and check it out!

Tuesday, February 19, 2008

Gaming Lunches at the LA Times

As a shameless promoter of the game of Go, I'm always trying to get my co-workers involved in the game. After talking to Reid, one of my co-workers, about various games that we enjoy playing, I decided to set up a weekly gaming lunch. The idea is pretty simple:
  1. Use Doodle to set up polls to choose a time and a game.
  2. Schedule a conference room for the weekly game.
  3. Order lunch for people.
  4. Have fun!
I'm proud to say that Go won the first week and consistently comes in second. The most popular game? Werewolf, introduced to our group by Giles Bowkett. It's apparently very popular at Ruby conferences, and our group has lots of fun with it too. Me? I like it because it excites people in a way that Go doesn't, and it keeps the lunches popular. And once in a while people decide to move on to something else, which means I get to introduce more people to Go. What can I say?

Saturday, February 16, 2008

LYSBYG: Let your stomach be your guide, and lose weight

I've lost weight by enlisting my stomach to help me in my quest for thinness. Since last June, I've gone from 248 pounds to 194 pounds, and for the first time in my adult life I'm under 200 pounds. People keep asking me how I lost the weight, and I've been trying to boil it down to some simple steps. The basic idea that I had was that I needed to make a permanent life change. Since I was pretty happy with the food I ate, I figured the permanent life change I needed was to reduce the volume of food that I eat. This worked amazingly well. I found that my stomach shrank, and I became physically unable to eat as much as I worked before. It's like getting your stomach altered to reduce the amount of food you can eat, only much, much healthier and cheaper! Here's what I did:
  1. Set a modest goal for myself, about 0.5% of my weight every week. (about 1 lb for me)
  2. I weighed myself every week at the same time, at least 1-2 hours after eating. (Sunday evening after dinner)
  3. I stopped cleaning my plate. Plate cleaning really is a habit that leads to overeating.
  4. I reduced my portions by a very small amount across every meal, every week I missed my goal, and increased my portions when I overshot my goal by losing 2 pounds or more.
  5. I stopped snacking except for when I felt physical, stomach-growling hunger. When I felt hungry like this, I would eat a small snack.
That's it! I know it sounds like something that takes an awful lot of will power, but it really didn't. Half a percent of your body weight isn't really all that much, and if you stick to that amount, you'll find that you're really not starving yourself. Plus, if you're really consistent about it, you'll find that your stomach actually shrinks, which means you'll feel satisfied with less food, and you'll feel physically full much faster.