2007-01-11 @ 23:14

First Post!

Wow. This is my first post of 2007. I’ve been really lazy about writing on here. I’ll try to catch up really quickly. My Birthday happened, and it was the best birthday ever. I’ll try to sum up my birthday in a couple pictures:

IMG_0203.JPGIMG_0209.JPG

That is a tiny head made in my likeness made from marzipan.

Then I went home for Christmas. That was a bunch of fun, but I really missed Seattle. I don’t know how anyone can be down on Seattle. I just can’t understand it. Salt Lake City is so crappy! I just don’t think people realize how good it is here! I think that any place you go will have crappy people, or things you don’t like. At least Seattle is beautiful. Anyway, I got a giant pan for Christmas, and we ate turkey:

Giant PanIMG_0261.JPG

I had to take the Giant Pan back because I don’t think it would fit through the door of my apartment. Also, I think it was just a wash tub that someone put a handle on and some non-stick action. I guess having a non-stick bathtub might be nice because you wouldn’t get soap scum. The only drawback is that it would be really slippery.

read more »

2007-01-13 @ 21:01

Graphing Objects in Memory with Ruby

I was debugging Mechanize the other day, and thought it would be handy to have a graph of objects in memory and they’re relationship with each other. So I put together a simple script that outputs a Graphviz file illustrating what the object points to. Here’s the code:

1
2
3
4
5
6
7
8
require 'ograph'
require 'rubygems'
require 'mechanize'

mech = WWW::Mechanize.new
mech.get('http://google.com/')

puts ObjectGraph.graph(mech, /^WWW/)

and the output:

Mechanize Memory Graph for Google

Right now it only supports Arrays, but should be easily extensible to support all other Enumerable types. Here’s the code for ObjectGraph:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class ObjectGraph
  def self.graph(target, class_name = /./)
    stack         = [target]
    object_links  = []
    seen_objects  = []
    seen_hash     = {}

    while stack.length > 0
      object = stack.pop
      next if seen_hash.key? object.object_id
      seen_hash[object.object_id] = 1

      if object.is_a?(Enumerable) && ! object.is_a?(String)
        object.each { |iv|
          if iv.class.to_s =~ class_name || object.is_a?(Enumerable)
            object_links.push([object.object_id, iv.object_id])
            stack.push(iv)
          end
        }
      else
        object.instance_variables.each do |iv_sym|
          iv = object.instance_variable_get iv_sym
          if iv.class.to_s =~ class_name || iv.is_a?(Enumerable)
            object_links.push([object.object_id, iv.object_id])
            stack.push(iv)
          end
        end
      end
      seen_objects.push([object.object_id, object.class])
    end

    s = <<END
digraph g {
    graph [ rankdir = "LR" ];
    node [ fontsize = "8"
           shape = "ellipse"
    ];
    edge [ ];
END
    seen_objects.each { |id, klass|
      s += <<END
      "#{id}" [
      label = "<f0> #{id}|#{klass}"
      shape = "record"
      ]
END
    }
    object_links.each_with_index { |(from, to), i|
      s += "\"#{from}\":f0 -> \"#{to}\":f0 [ id = #{i} ]\n"
    }
    s += "}\n"
    s
  end
end

Update: added Enumerable support, so Hashes are now graphed.

read more »

2007-01-16 @ 19:25

It Snowed Today

It snowed today in Seattle, so I thought I’d share some winter driving tips. I come to you with over 20 years experience living in a snowy place and over 4 years driving in that crap, so hopefully people will take heed to these steps.

IMG_0024.JPGIMG_0027.JPG

Here are my tips for safer driving:

  1. Cut a hole in the box
  2. Put your junk in that box
  3. Make her open the box

and thats the way we do it! Next week I’ll post some tips on how to lay your girl down by the fire and make some sweet love.

read more »

2007-01-22 @ 21:19

ograph version 0.0.1 has been released!

ObjectGraph will output Graphviz dot files of your objects in memory. It will ferret out your instance variables and enumerate over your enumerables to give you a graph of your object and its relationships.

For sample output and more sample code see:

  • http://flickr.com/photos/aaronp/tags/graphviz/
  • http://tenderlovemaking.com/2007/01/13/graphing-objects-in-memory-with-ruby/

Changes:

0.0.1 / 2007-01-14

  • Birthday!
read more »

2007-01-26 @ 22:42

Trapped with the Isley Brothers?

The other night Pam and I were going to study for Japanese Class, and we got in to a discussion about the Isley Brothers. I was under the impression that R. Kelly’s Trapped in the Closet was basically a rip off of earlier work done by the Isley Brothers, and not in fact a totally original thing that would revolutionize the world as Robert had indicated in the DVD commentary.

I would like to share my findings with everyone so that the record can be set straight.

The only recurring figure in the Isley Brother’s videos is “Mr. Biggs”. I’ve only been able to find that character in 4 videos. He first appears in the video for R. Kelly’s song “Down Low”.

In this video Kelly makes sweet love to Biggs’ girl Lala, even after Bigg’s tells Kelly that Lala means everything to him. At the end of the video, Bigg’s busts him with his woman, takes him to the desert and drags him through the dirt. The viewers are left with many questions. How does Kelly know Biggs? What is the history between Lala and Biggs? Why did Biggs only need “say a half a minute” at the beginning of the video?

read more »

2007-01-27 @ 18:36

Best Dollar Store Ever

Today Pam and I went to a store called Daiso which is a popular 100 yen store in Japan. Sort of like our Dollar stores, but much more clean and way better stuff. Most of the stuff is $2 or less, and most of it is pretty good stuff.

Here are a couple things I picked up today:

IMG_0067.JPGIMG_0072.JPG

The first one is inflatable boobs that you put under your shirt. That was 2 bucks. The second one is a swan head that you stick to your junk and squeeze it and the head will inflate. Check out the instructions on the back of the boxes.

IMG_0069.JPGIMG_0074.JPG

read more »