Thursday, November 11, 2010

Using Spaced Repetition Software to Master Vim

I've been a vim user for about 20 years. During that time I've used IDEs and other text editors, but I've never found one to fit my needs better than vim does, and I always end up finding my way back to vim. As a developer's editor, it's really making inroads in the Ruby community, which I love because it means there are lots of great vim plugins being developed and improved right now, and my experience with vim is getting better all the time.

However, I've also found that I'm often aware that a particular command exists, but I don't remember it long enough to be able to use it when I need it. It's a pain to have to look up a command when what I really want to do is to write code. So, I've gotten to a set of core commands that I know, and when I get that particular itch, I take the time to look up a particular command, use it, and usually forget it sometime in the next 24-48 hours. It turns out that when you learn something, if you fail to reinforce or exercise that knowledge you will inevitably forget it. When was the last time you tried to remember a list of capitol cities that you memorized in grade school? You use it, or you lose it.

Spaced Repetition Software

Spaced Repetition Software, SRS for short, is software that keeps track of how long it takes for you to forget something, whether it's vocabulary in a foreign language, state capitols, or other facts, and refreshes your memory at just the right time to keep you from forgetting. I first learned of SRS through Piotr Wozniak's SuperMemo (which is about incremental reading as much as it is about SRS), but there are many flashcard-only systems out there that will drill you on things you want to remember.

I asked on Twitter if anyone knew about flashcards for vim and didn't get much response. I think the very notion of SRS is new to people (it was new to me), so there's not much activity in this area. Still, I started to think that this could be an excellent solution to my problem of learning new vim commands: If I could simply memorize a bunch of commands, those commands would be ready at my beck and call when I was writing code. It was time for an experiment.

Enter Anki

I checked out a few different SRS systems before settling on Anki , which is free and open source, and available on Mac, Windows, Linux, and Android. There is also an iPhone version that will set you back $25, and an open source program called Mnemosyne that does SRS.

Vim Commands Stack

So, the Vim Commands flashcard stack was born. I started adding commands that I wanted to learn, guided by quick reference cards, vim's own excellent help system, and my own vague notion that "there's a command for that, if only I could remember what it is…"

I started spending just a few minutes a day memorizing and reviewing commands, and collecting more commands, until I had a pretty decent collection. The experiment started bearing fruit almost immediately. I was able to remember some of the more obscure cursor movements, search commands, advanced undo commands, and so on. Before long I was giving my co-workers tips on advanced commands that would help them out.

Today the stack has 241 commands, many of which I knew existed but never could remember when it was time to use them. I regularly pause to remember a command and it comes to me quickly. Some of these commands have already become part of my muscle memory, and it feels like many more are on their way.

Github Project

I've exported the stack from Anki and am keeping it in a text format that is easy to edit and re-import to Anki. I've reordered the facts in the deck to start with Basic commands, progress through Beginner commands, to Intermediate and Advanced commands. The Github project is called vim_flashcards and the all_cards.txt file is suitable for import directly into Anki.

Currently the cards are all stored in a flat file, but I'm thinking about creating a Ruby gem for managing SRS flashcard stacks and exporting them to multiple systems. Please contact me if you are interested in helping out with this effort.

Getting Started With Anki

You can begin by downloading Anki and installing it. Once it starts up, click on the "Download" button and search for "Vim Commands". Alternatively, clone the github repository and import the cards into Anki from the all_cards.txt file.

When you open the deck, be sure to tune the goals to your liking. For beginners, I would recommend no more than 5 new commands per day; expert users might want to stick with 20 or even set the value higher. Remember, if you're trying too hard, you might fatigue out.

Conclusion

My vim flashcard experiment is still in its early stages. I'm still adding new commands on a regular basis, and still trying to organize the stack so that it is presented in an order of increasing difficulty, with the easiest and most useful commands at the beginning, and the harder and more esoteric commands at the end. It will be interesting to see how relevant the stack is to me in the long term: will it be necessary to keep commands in mind, or will I use all of them regularly enough that refreshing them with Anki becomes redundant?

I invite you to participate in the experiment and provide feedback. If you use the vim deck, let me know if you find it helpful, whether you're brand new to vim or an old hand. Actually, if you're brand new to vim, I recommend that you first go through vimtutor (type "vimtutor" at the command line and start reading) before trying out the Anki deck.

If you use a different text editor, like emacs or TextMate, you might want to create your own flashcard stack to help you remember all the commands for your editor.

Happy editing!

Tuesday, October 19, 2010

Where is all the Linux Shareware?

I'm back on Linux. No, really. After about 8 years of OS X, I've made the move back to Linux. Ubuntu, to be specific. Don't get me wrong — it's not that I have something against OS X. It's Apple and Apple Fandom I don't like (and the fact that Steve Jobs has recently taken over as the Evil Sith Lord).

It's only been a few days, but so far I'm really liking Ubuntu. It installed pretty easily on my '07 MacBook Pro, and although the trackpad is a little spotty, I can live with it. I'm even ok with the minor glitches in the video display and other little bugs I can work around. It's all cool, and frankly, it's a heck of a lot better than Linux was 8 years ago.

So what do I do when I come back to this somewhat edgy environment? I start looking for shareware. You know, handy programs written by independent developers that you can try out for a time before deciding to pay for it. There's plenty of it for Windows, and there's plenty of it for OS X as well. In fact, I'm especially impressed with the quality of software available from independent developers for OS X. It turns out there's not much software that you can actually pay for, if you have a Linux desktop machine.

I know, you're thinking this Alf guy is pretty crazy, wanting to pay for Linux software when Linux is all about Free-As-In-Speech. But guess what? There's no money in Free. Oh, but you already knew that.

Open Source software is wonderful. I make my living as a software developer using (and sometimes releasing) Open Source Free-As-In-Speech software. I believe standards should be Free. But I'm also practical, and my time is very limited. Creating something that's fun and scratches an Itch is really important, and I do that when I can. And I release it free of charge. And yet, I want to pay other developers for software. Why?

Well, here's the rub: Creating something that mostly works is fun, even if it's kind of buggy for cases that I don't care about too much. Creating something that's flawless, and works smoothly for a broad class of users takes real work. And at the end of the day, software developers only get paid for doing real work. Sometimes I need software that's more or less flawless, and it's hard to find that kind of software for Linux.

This week I read an article about how Linux on the desktop is dead. I know it's not really true, but if Linux is going to ever really thrive on the desktop, it's not going to happen on Free software alone. So take a few moments to seek out useful Linux software that's useful and NOT free, and spend a few bucks (or euros or pounds) in support of an independent software developer.

In the end, we'll all benefit if you do.

Monday, August 9, 2010

U.S. Go Congress 2010 Report

At the beginning of August, I attended my first U.S. Go Congress. After a few years of telling people that "I'd like to go" and "I can never quite seem to make it happen", I realized that I simply wasn't trying hard enough. So, I did what I needed to do to make it to the Go Congress this year.

Background

If you don't know what Go is, check out the American Go Association's description of Go. I also highly recommend The Interactive Way to Go, which will teach you about the rules and basics of the game, and give you simple puzzles to test yourself.

This year the 28th annual U.S. Go Congress was held in Colorado Springs. The Congress is a week-long convention where people from all over the United States (and in some cases other nearby countries like Canada or Mexico) come together to play, talk about, and study Go. Professional players come from all over the United States, as well as Japan, China, and Korea, to teach and to play.

Eight Days of Go, not Nine

Back when I got my plane tickets for the Congress, I made a rookie mistake: I scheduled myself to fly back home on Sunday night, figuring I wouldn't miss anything that way. Well, it turns out that after the banquet and awards ceremony on Saturday night, there's basically nothing else to do. People fly out the same night, or the next morning. When I mentioned this to people at the Congress, I found this is actually a fairly common mistake. This year's Congress went from Saturday, July 31st, through Saturday, August 7th.

The Main Event: The U.S. Open

The main event at the U.S. Go Congress is the U.S. Open. This week-long tournament runs from Sunday through Saturday, and consists of six games with a day off on Wednesday. The time limit is one and a half hours per side (2 hours per side in the upper dan divisions), with 5 30-second byo yomi periods. That's twice the typical time limit in a Go tournament! I wasn't sure if I could handle the longer game, but I actually used up all of my time in the first two games of the tournament, and hardly noticed that the time limit was so much longer.

Professional Game Reviews

In the afternoons, there are a lot of opportunities to attend scheduled game review sessions, where professional players would go over your game with you and help you to understand how to improve your game. I found this extremely helpful, and sometimes when a professional would point out the best move, it turned out to be the next move I played. Other times, the response would be "I played that later". In fact, it seemed to become kind of a running joke, with players admitting "I played that later" as opposed to as the next move in the game. Still, it's good to feel that we were finding the right moves, even if the timing wasn't perfect.

I attended game reviews by Jennie Shen, Mingjiu Jiang, and Xuefen Lin. In fact, I was lucky enough to attend a review by Xuefen Lin with only one other person, and it turned into something more like a private lesson, a game review where we had enough time to go over the entire games and lots of variations. She also shared a favorite tesuji from a recent professional game that she had studied. It was really a rare opportunity to get to know a professional player a little bit better.

Other Tournaments

There are a number of other tournaments that take place at the Congress, including 9x9 and 13x13 tournaments, the Die Hard Tournament (a 1-day tournament that takes place on the day off from the U.S. Open), the Redmond Cup (a youth tournament named for Michael Redmond, the only non-Asian in history to achieve the professional rank of 9 dan), and the Ing Masters Tournament (attended both by professionals and strong amateur players).

The Lectures

I attended lectures by several professionals, including Ryo Maeda, whose series of lectures has been very popular among kyu players for the last 10 years, Yilun Yang, and Mingjiu Jiang. I walked away from all of the lectures with valuable lessons about how to approach my game, and in my recent games I'm still applying the principles I learned.

Other Events

There are other presentations at the Congress that gave me a chance to learn about events going on in the world of Go. This is another area where the Congress materials could be a little bit clearer! Before the Congress, I was wondering if there was room to do discussions about community projects, but it was hard to find anything about this on the Congress site. There were presentations from GoGoD, GoClubsOnline, and there was one scheduled for IgoLocal.net, but unfortunately Chuck Thomas couldn't make it to the Congress. If you're not familiar with IgoLocal.net, it's basically the same service as the PromoteGo.org project that I've been working on, on and off, for the last couple of years. I'll talk a little more about that in a future post.

Next Year

I had a great time at the U.S. Go Congress this year! It definitely made me a stronger player, and it really inspired me to work on my game again. I also met some great people in the U.S. Go community, and made some new friends. I really wish I had gone to some of the previous Congresses now.

Next year's U.S. Go Congress will be taking place in Santa Barbara! Santa Barbara is one of my favorite vacation spots. Hopefully this beautiful city will inspire a lot of Go players to come, and to bring their families. We need lots of volunteers, from Saturday-only registration volunteers (which doesn't interfere with the Congress at all...there's not much that happens on Saturday) to Treasurer and Tournament Director positions, which require a much larger commitment. If you're interested, please see the list of available U.S. Go Congress Volunteer Positions.

Monday, May 31, 2010

Bilski, Software Patents, and Patent Reform

In the last month, I've been hearing more about software patents. I've always thought software patents were stupid since I first discovered that someone had managed to get a patent on "backing store", the notion that windowing systems could save a copy of the pixels that have been obscured by a graphical window in order to display them back more quickly once the window was moved away again. Anyway, it turns out that the Supreme Court is about to rule on In re Bernard L. Bilski and Rand A. Warsaw, which stands to be a landmark ruling of the SCOTUS. The patent claim has been rejected by the court of appeals, and it's expected that sometime in the month of June, the Supreme Court will rule on the Bilski patent application.

It's largely expected that the Supreme Court will uphold the decision of the lower court, and it's possible that the Supreme Court will decide that business methods cannot be patented. Since business methods are very similar to software algorithms, it seems possible that the Court will decide that software is also not patentable, but however hopeful I am that this may happen, that seems unlikely.

So, I'm continuing my self-education about software patents. It seems that there is plenty of innovation in software, and that patents are not necessary to promote innovation. The software industry moves so fast that even a 1-year head start can be a huge boon for a company, so maybe that's a reform to consider: reduce the patent lifetime for a software patent down to 1 year. That would be a step in the right direction!

For a great summary of how software patents got to the state they're in today, watch the Patent Absurdity video. There's also a lot going on over at End Software Patents, and I also found out where you can donate to the FSF's Fund to End Software Patents. Are you involved in software patent reform? Have some good resources? Post them here!

Sunday, April 25, 2010

Keeping up with all those habits

At the beginning of the year, I announced on this blog that I would average a blog entry per month, and two Facebook updates per week. The idea is that there are a lot of things that I would like to be in the habit of doing regularly, and starting a new habit for a new year has worked well for me in the past.

I'm happy to say that I'm doing reasonably well with those two habits, but thinking about those habits and all the other things I'd like to be doing regularly got me to thinking: Wouldn't it be great to have a tool to help track all those habits? So, being a web developer, I started writing exactly such a tool. It's helped to remind me when I'm overdue for updating this blog, and when it's time to take the dog for a walk, when it's time to check the oil in the car, do the bills, take out the trash, etc. I even have a habit set up to remind me when it's time to work on the app itself!

Well, it's very much a work in progress. There's not yet a way to keep track of accounts, so at the moment it's only good for one user, but I plan on adding user accounts soon. Let me know if you're interested in beta testing it!

Saturday, March 6, 2010

Life with Nexus One, part II

I still love my Nexus One! I just wanted to comment on a couple of things:

  1. Battery life
  2. Swype beta
  3. QR Codes

Battery life

Regarding battery life...I was at a LARubyConf a couple of weeks ago, and my battery drained like crazy all day both days, even though I wasn't really using it all that much. My theory? 3G signals were weak but present, so the phone was constantly trying to connect to a 3G network. Solution? Turn off 3G, problem solved!

Seriously, do we really need 3G anyway? I mean, it's nice to have faster networking, but that's why God invented WiFi, right? I'd much rather have WiFi than some proprietary cell network.

Swype beta

I joined the Swype beta this morning. So far I haven't used it much, but it really is a lot faster than typing on a touch keyboard. You basically just drag your finger from letter to letter and the predictive text system does the rest. Check out this smackdown video and prepare to be impressed!

QR Codes

I really love the QR codes that often go along with reviews of Android apps. It's so easy to just scan the QR code off the screen and go right to the download for the app. It's really sweet.

Saturday, February 6, 2010

Life with the Nexus One, part I

I bought a Nexus One directly from Google for full price, the week after it came out. I had been waiting for an Android phone for most of 2009, and the Nexus One looked like the phone for me.

A phone that doesn't suck too much

My primary goal for getting an Android phone was to find a phone that doesn't suck significantly more than the iPhone. I mean, let's face it: walled gardens suck. Also, you can't use it on any network besides AT&T without jailbreaking your phone. The way I see it, smart phones are computers, plain and simple. I wouldn't dream of buying a computer that wouldn't let me run whatever I want to run on it.

So the iPhone sucks, but then so do most Android phones. Look at how ugly and clunky the G1 and MyTouch are. And the screens are so small. And don't forget, you have to buy them from T-Mobile!

The Nexus One is the first of the current generation of smart phones that you can buy without a contract. It's an open platform. And nobody is trying to tell me what I can or can't run on it. The touchscreen is actually the same size as the iPhone, and the touch buttons directly beneath the touch screen give you some good contextual actions that you can take, so most apps are able to make better use of the screen real estate than the iPhone allows.

Don't get me wrong, the Nexus One still sucks. The battery life isn't what I would want. There's also a slight design flaw with the location of the speaker pointing towards the back of the phone. In loud environments, I find myself wanting to point the screen away from me so I can hear the speaker. Pretty annoying.

The Camera

The Nexus One comes with a 5 megapixel camera. I've had trouble sometimes with the automatic white balance making pictures more yellow than they should be, but overall it takes really great pictures, and the autofocus lets it take really close pictures, really sharp.

Autofocus combined with the 5MP camera leads to really fast decoding of bar codes and QR codes.

The Apps

As a Go enthusiast, I'm a little bit disappointed by the number of Go applications on the Android market. I haven't yet found a great app for recording Go games, although an open source app called "gobandroid" appears to be making some really great progress.

There are tons of both free and for-pay apps in the Android Market. I don't see any shortage of applications really.

Battery Life

The battery doesn't seem to last as long as the battery in my iPhone 3G did. I'm not sure what the reason for this is, but it could be due to a number of factors, not least of which is the fact that I'm always messing around with the phone. Background processing may account for some of that, but I don't really know.

Email

One of the things I really hated about the iPhone is the fact that it took me so many steps to check email:

  1. Unlock the phone
  2. Run the "Mail" app
  3. Select the correct email account
  4. Select the inbox
  5. Wait for the client to connect to the mail server
On my Nexus One, there's only one step, thanks to background processing and a helpful status bar:
  1. Press the "standby" button
  2. There is no step 2

The Verdict Thus Far

So far, I really love my Nexus one. I'm still discovering new apps and new things about the phone, but I really use it a lot more than I ever used my iPhone.

Thursday, December 31, 2009

New Year's resolutions, 2009 and 2010

Ok, wow. I made a New Year's resolution last year to write a blog entry every week. After falling hopelessly behind in February, I gave up on blogging entirely. Ouch, ouch, ouch.

Actually, I made two resolutions on this blog last year:

  1. Tweet at least once a day
  2. Post at least one blog entry a week on one of my blogs
How did I do with my other resolution? Pretty good, actually. Well, sort of. I certainly didn't tweet every single day, but that wasn't really the point. I was going for the daily average. According to TweetStats, I tweeted 587 times last year.

So one for two? Not bad. But what went wrong with that resolution that I missed on? I think it's pretty simple:

  1. Make a resolution you can stick to.
  2. Renegotiate your resolutions if you need to.
So yeah, a blog post every week is way too much for me, with all the other things I have going. And when I realized I couldn't keep up the pace, I should have simply changed my resolution to something attainable.

This year, I'm going to stick to a similar theme. It's about forming habits. And it's about social networking:

  1. One blog entry per month.
  2. Two facebook updates per week.
These are both things I can easily stick to, and can definitely overshoot if I try. But the resolution is about forming a habit, not so much about meeting a goal.

Oh yeah, and this post doesn't count towards the 12 blog posts I'm resolving to write this year!

Thursday, February 12, 2009

Branching after committing locally in git

Today I found out that one of my co-workers had a local commit that he wanted to undo, so that he could work on another task that he actually wanted his earlier commit to come after. His question was: How do I undo a commit but keep the files? The answer to that is simple: simply use git reset HEAD^ to point master to the commit before the current HEAD. By default, this leaves the checked out code alone, and it remains as uncommitted changes locally. git reset --hard will check out the previous changes and blow your commit away completely.

On the other hand, branches in git are essentially just pointers to nodes in the repository tree. So, consider doing this instead:

  1. git checkout master
  2. git branch new_branch
  3. git reset --hard HEAD^
What does this do? It creates a new branch that points to the HEAD of the current master, then resets master to point to the previous commit from HEAD. Once that's done, you can continue working in the branch, or make further commits to HEAD. Then, when you're ready to continue work in new_branch, you can rebase it against master and continue on your way as usual!

Sunday, February 8, 2009

Gaming Lunches at AT&T Interactive

I started a new job as a Ruby developer at AT&T Interactive (AKA YellowPages.com) in Glendale, CA, back on December 1st. While I've organized gaming lunches at my previous two companies, I've always been a little bit conservative, worrying about being too successful and not being able to handle too many participants. Ha!

Well, having too many participants is a problem I'd love to have. So, I decided to go all out on this one. I worked with HR to send out an allstaff email to get participants. I made up fliers with pull tabs giving the e-mail address to contact to join the mailing list. I hold the gaming events in the main break room, which has room for plenty of people. And I'm varying the games played from week to week so that we'll cover a wide variety of choices, and hopefully we'll bring more people out because of it.

So far, we've played Scrabble, Rummy, and Chess. Scrabble had the best turnout so far: 8 people. Chess was close, with 7 players. This week we'll be playing Hearts.

I have 35 people total on my mailing list so far, and hopefully I'll be able to build the events and get more regular players. These kinds of events need to reach a critical mass before they can be self-sustaining. The group has to be big enough to be able to lose a couple of people here and there and still have at least 5 or 6 attendees every week.

I'll be updating with my status periodically. Have you ever organized an event like this at work? I'd love to hear from you!

Thursday, January 1, 2009

New Year's Resolution: 365 Tweets, 52 Blog Entries

Well, 2009 is upon us, and for those of us who believe in them, it's time to make our New Year's resolutions. I have to admit, I've been one of those people who don't believe in New Year's resolutions. After all, if you're not eager enough to do something right now, you're probably not going to stick with it. Want to stop smoking? Do it when you're ready. That might be on January 1st, but it may just as well be on any other day of the year. So why bother making resolutions? And how do you make a resolution that's going to stick?

It's really refreshing to look at today as the first day of a completely new year where I can change important things in my life. Some of those things I wonder about, and others I just have to have the resolve to do, and they are in my reach.

Last year, I made a simple and attainable resolution that I hoped I would be able to stick with, and that would get me back into a habit that I'd been sorely missing: I resolved to read a novel every month. It's a resolution I was able to keep. I didn't have to work too hard to do it. I had about 50 minutes of reading time on the train every day during my commute from Pasadena to my job Downtown at the LA Times. I ended up reading 16 novels last year, up from only two novels in the previous five years.

Why did it work? I think it worked because all I needed was to form a new habit. I had plenty of time to read the books, it was something I truly wanted to do, and all I needed was to make a commitment to myself that I was going to take the time to do it.

This year I'm resolving to be better about social networking. Everybody I know is already involved with social networking, and I'm partly involved already. I know that if I improve my social networking, it will be good for both my personal life and for my career. I have a decent LinkedIn profile, a Facebook account complete with friends from high school I still don't talk to, a Twitter account, and several blogs that I haven't updated in a while. I'm picking two of those for improvement: Twitter and blogging.

For those of you who don't know Twitter, you should really check it out. It's a great way to stay connected to people around you, and of course it's a lot more fun, the more people you know who are active on Twitter.

So, this year, I resolve to:

  • Tweet at least once a day
  • Post at least one blog entry a week on one of my blogs
Good luck to all of you in the new year!

P.S. Yes, this blog post counts as my first of the year. Maybe this is gonna be too easy. I'm already 1.92% of the way there!

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

SuperDuperApps.com

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!