Dinner and BSG

Yosh and I have been planning to do a BSG (Battlestart Gallactica) marathon for  a while now. Finally we broke down and decided instead of doing a marathon, we'll just one episode at a time with our dinner. Here's to the beginning.

We had vegetarian Chili, Garlic Bread, Hash Browns and Beans with sesame seeds. 

Cows and Bulls == Master Mind

I found out during my Utah Python meetup that the game I created called Cows and Bulls is actually called MasterMind in the US. 

It's a really simple game. 

The computer thinks of a 4-letter word. You start guessing that word and the computer will give hints along the way.

Cows - Number of characters in your guess that match the original word, but placed in a different location.
Bulls - Number of characters in your guess that match the original word, found in the exact same location. 

Based on the hints from each turn we can narrow down the possibilities and finally reach the answer. 

It's a fun game and really easy to implement.

pTimer listed in Softpedia

One of my hobby projects is now included in the Softpedia Mac OS database. I don't know if that means anything but it is fun to see that 9 people have downloaded that utility so far. 

A while ago I wrote a little PyQt4 application called pTimer to try out the famous Pomodoro Technique for productivity. 

The original reason why I wrote that timer was to get myself acclimatized to Qt programming using Python. But since I liked it so much I decided to publish the code and host it on Google Code hosting. 

Yesterday I got an email from Softpedia about including that utility in their website. Pleasantly surprised.

Utah Python Users Group - 11/11/10

I've been messing around with Python for the past 6 months and I'm loving it. Today I went to my second UtahPython users group meeting and had a lot of fun and learned a ton of stuff.

Chronological order of things I learned:
  • Supy bot - an IRC bot written in Python. 
  • supybot-doxygen - A plugin for supy bot that can provide api documentation for any software that uses doxygen.
    • This could be really useful at work if I can setup an internal IRC server for the developers to hang out. 
  • Objectify is a module in python for parsing XML files. 
  • doctest - a python module for TDD that is super simple. I'm really excited about this. Thanks to Matt for showing me how to use this.
Matt suggested that we do some pair programming during the meetup.
Here's the task: Write a simple python program that can take page numbers as user input and convert it to a list of numbers. 
User Input: 0, 1, 5, 7-10
Output: 0,1,5,7,8,9,10
Here is the code I wrote with the doc test based unit test in the doc-string:
###### PrintParser.py #######
    
    #!/usr/bin/env python

    def convert(inp):
        """
        * Get the input from user.
        * Parse the input to extract numbers
        ** Split by comma
        *** Each item in the list will then be split by '-'
        **** Populate the number between a-b using range(a,b)

        >>> convert("")
        []
        >>> convert("1")
        [1]
        >>> convert("1,2")
        [1, 2]
        >>> convert("1,2-5")
        [1, 2, 3, 4, 5]
        >>> convert("1-3,2-5,8,10,15-20")
        [1, 2, 3, 2, 3, 4, 5, 8, 10, 15, 16, 17, 18, 19, 20]
        """
        if not inp:
            return []
        pages = []
        comma_separated = []
        comma_separated = inp.split(",")
        for item in comma_separated:
            if "-" in item:
                a = item.split("-")
                pages.extend(range(int(a[0]),int(a[1])+1))
            else:
                pages.append(int(item))

        return pages

    if __name__ == '__main__' :
        import doctest
        doctest.testmod()

Hapkido First Impressions

I went to my first Hapkido class today. I have a very good (and respected) friend from work, who is already taking that class and he recommended it.

I had high hopes for that class, maybe a little too high. It was a little bit underwhelming due to my overtly hyped expectations. It is definitely more exerting (physically) than Aikido. It combines the kicks from Taekwondo with the joint locks in Aikido. So I'm excited to keep learning the art. But the part that bothers me about Hapkido is you attack to destroy, unlike Aikido where you take care of your opponent even when you are pinning them down and making them submit. 

But one great thing about the class is the instructor seems really good. He is very friendly and knowledgeable. If you are in Lehi/American Fork area you should check out the class. xsifactory.com/martial-arts-classes/