Generating N colors (Ruby)

Kevin messaged me a few days ago to give me a problem his boss had given him. Generate a list of colors that can be used when drawing n lines on a graph.  My first solution was to just pick 20 or 30 colors, put them an in a list and pick one of them for each graph, but I had a few other ideas.  One of them seemed stupidly-simple, so I threw it together in ruby and had it generate an html page to display the results.

maxColors = 250'colors.html', 'w') do |myfile|  #create file
    myfile.print "nnn"
    1.upto(maxColors) { |tblcnt|
        myfile.print "n"
        1.upto(tblcnt) { |rowcnt|
            newColor = (rowcnt * (0xFFFFFF/tblcnt)).to_s(16)
            myfile.print "n"
        myfile.print "
n" } myfile.print " nn" end

Here are the results from my code:

Click for html (warning 1MB file)

Click for html (warning >1MB file)

The code basically takes 0xFFFFFF, divides it by n and displays each color.  It’s a simple hack, but the patterns it generated were just incredible.  Most of the color lines aren’t distinct enough to use in graphing, so it doesn’t really match what Kevin asked me to do.  Oh well, it was a fun little script to write.

Work on my new house

Stripped-away garage ceiling

Stripped-away garage ceiling

I got the keys to my house last Wednesday and have been working on it almost non-stop since.  I decided to start on the garage, tear out the paneling and have a new door installed before I move in.  My dad and I removed the paneling and saw that there was some framing tomfoolery, so we decided to redo all the garage framing while we’re working on it.   The garage was also crappily-carpeted,  so we tore that out and spent nearly a day scraping the carpet glue off the floor.


In between scraping crap off of the garage floor I finally took the time to tear up the carpets in the bedrooms.  Three of the four bedrooms have pristine hardwood floors.  Awesome!  The Master bedroom floor is trashed, but this means I can just carpet the master and leave the other floors as-is.

KHAN! (Ruby)

This evening I read a story on reddit in which someone graphed the number results google gives vs. the number of A’s in “KHAN.”  KHAN! is from the second Star Trek Movie, “The Wrath of Khan.”  The original results from that article are here.  I thought it was pretty funny, so I decided to write a ruby script to automatically do the same thing (I’ve been using ruby a lot lately).

require 'gruff'
require 'open-uri'

dataToGraph =
khanNumOfAs = 1
maxKhanAs = 100

g =
g.title = "KHAN!"

    sleep 0.5
    open('' + "A"*i + "N") do |f|
        f.each do |line|
            dataToGraph[i] = $~[1].gsub(/,/, "").to_i if /of about ([0-9,]+)/.match(line)
    print "KH#{"A"*i}N!!!!!    results: #{dataToGraph[i]}n"
}"KHAN!", dataToGraph)

Kevin helped me with the regular expressions to get the number of results out of google.

Final results, no log scale :-(

Final results, no log scale 🙁

Look at me. I’m Dr. Zoidberg, Homeowner!

click for pictures of my house!

click for pictures of my house!

Since I graduated I’ve been looking for a house, but my requirements were pretty specific.  I wanted something in a great neighborhood, a two car garage, close to my work (Folsom), a fixer that had a lot of cosmetic damage, and a big yard.

After over a year of looking, I finally found it.  The house is in a fantastic neighborhood of Citrus Heights, close to two Elementary schools, a park, and a country club.  It’s 8 miles from work, which makes my drive around 20 minutes.  It’s a four bedroom, two bath, 1550 square feet, 0.23 acre lot, 2 car garage, and has central heat/air.  It needs a lot of work, but nothing too major (the biggest fixes will be a new garage door, new floor in the kitchen, and possibly tearing out the carpet and refinishing the hardwood floors).

Picture this.

Ever since I lost my last point-and-shoot to the murky depths of a moat in Long Beach I’ve been looking to get a new camera.  I bought someone a Nikon D40x as a gift before and really liked it so when I started look for cameras again I wanted to get something similar.  This year Nikon released an updated version of the D40x, called the D60 and on Black Friday most big stores had them on sale, so I bought one.

Next year I plan on traveling quite a bit, so this will be a good companion.

Japanese 1B skit

Finally found the skit from my second semester of Japanese.  It was the intro scene to 300 the movie…

Ryan: (riding on horse into Sparta – slow motion – dramatic!)
(they meet)
Joe: まえに話します、あなたのたんごはちゅういつくります。
Before you speak, make your works carefully. Careful: (ちゅうい)
Ryan: ….(puzzled)
Joe: だれですか。どこから着ましたか。
Who are you? Where are you from?
Ryan: おはよう。名前はライアンです。ぼくはペラシアの会社員の人です。度おうぞよりしくおねがいします。
Good morning, My name is Ryan, I am a businessman from Persia. Nice to you meet you.
Joe: はじめまして。この 何おしますか。
How do you do? What are you doing here?
Ryan: つちとみず。
Earth and water
Joe: 何。つちとみずから、着ましたか。
what? You came for earth and water?
Ryan: しょうらいにおとなしいから、XERCESさまつちとみずをもらってください。
In the future, because you are obedient (おとなしい), Please give Xerces earth and water.
Joe: XERCESさんはどんなの人がですか。
Who is xerces?
Ryan: XERCESさまはかみです。せがたかくて、とてもつよいって、大きい手です。
Xerces is a god. He is tall, has big hands, and is very strong.
Joe: とにかく。。。スパタンスはおとなしないです。
in any case, Spartans aren’t obedient
ryan: どうして。一万ペラシアの国!わたしたちはいちばんつよいですよ。けんかしますか。
Why? There are ten thousand Persian countries. We are the strongest, do you want to fight?
Joe: しんでいるこくおうのあたまをもってきますよ。私の人がおどしをもっていますよ。
you bring the heads of dead kings(こくおう) , you threaten(おどし) my people.
Ryan: Xercesさまはこくおうになりたいです。つちとみずはもらいてくだいさい。
Xerces wants to become your king. Please give us earth and water.
(point sword)
Joe: つちとみずはしたにあります。
You’ll find a lot of earth and water down there.
Ryan: このへんですよ!会社員はしんでいません。
This is strange, no one has ever killed a businessman!
Joe: このへんですか。このスパタ!
Strange? This is Sparta!

Reno Air Races 2008

Went to the Reno air races Sunday…it was probably the coolest thing I’ve ever seen.  I got to see jet races, unlimited races, and an F22 raptor demonstration.  As soon as I make my first $20 million I’m pretty sure I’ll be buying a P-51 mustang and racing there.  Unfortunately, because I dropped[killed] my camera when I was in Long Beach, I didn’t get any pictures :-(.  Speaking of cameras, I don’t think I’m going to buy another cheap point-and-click.  I bought a Nikon D40x before and really liked it (but unfortunately lost access to it).  I’m starting to travel more and thinking about buying it’s predecessor, the D60.  Seems like a good investment.

Japanese 1A skit

I took two semesters of Japanese when I was in school and absolutely loved it. I was cleaning up my document folders today and found the skit from my first semester. There are a bunch of mistakes(it was my first semester) but it was too funny to not post:

A: Do you want to go to a restaurant now?
B: yes, should we ride the bus?
A: yes.
—-riding the bus—-

C: Would you like me to bring you some drinks?
A/B: yes, some sake!
はい! おさけをもってきます!
C: What do you want to eat? Should I bring some sushi?
B: No, bring me a hamburger.
A: A hamburger?! This is a sushi restaurant!
ハムバガですか?! これすしのレスツラウンですよ。
B: Oh sorry, please bring me some sushi.

—-bring food—-

A/B: Thank you.

A: What is that thing swimming in the sea?
B: Is it a bird? Is it a plane?
A: It’s Godzilla! Is he taking a bath?
あのゴジラガアリマス! ゴジラはおふるにはいりますか。
B: No, he is attacking Tokyo!
A: Tokyo? We’re in Sacramento!
B: Excuse me. He is attacking Sacramento!
—-Godzilla attacks Sacramento—-
—-Nick Goes and Changes into Godzilla—-

A: He is attacking a café!

G: I’m disgusted with cafes! French Cafes are very expensive!

—-crushes café—-
A: He’s eating a train!
G: I neither like nor dislike eating trains.
A: No!
—-Eats train—-
G: I hate the post office! The post office is very bad! E-mail is good.
ゆうびん のでん気ええです。

—-Destroys Post Office—-
A: Uh
G: He, Hi, Ho, Fu! I see a little man.
へ!ひ!ほ!ふ! 私はちいさい人を見ます
A: He is coming here!
—-Godzilla Grabs Man—-
G: I am eating you. Please die.
—-dramatic death scene—-

Long/Huntington Beach – Summer 2008

Click for the gallery

Click for the gallery

This last weekend I went with my sister to Long/Huntington Beach. We stayed with some of her friends and had a lot of fun. I would have taken more pictures but I fell out of a kayak and doused my camera…so that’s where the pictures stop. Saturday night we went to a piano bar, which was a blast. We requested a bunch of songs, but my favorite for the night was Smells Like Teen Spirit. I also requested Tie Your Mother Down, but they didn’t know that song 🙁