25 October 2008

BabyBoy as Dragon...or not!

I've had this costume for BabyBoy for quite a few weeks now, but we thought we should try it out this afternoon, since Halloween is next weekend. Here J and D are getting started, and BabyBoy is not too sure what he is getting into.



Now he has the costume on, but not happy about it.



Definitely not happy!

23 October 2008

Pumpkins at Whole Foods

5th and Lamar, Austin, Texas.

21 October 2008

You can see Alaska from here

6th and Nueces Streets, Austin, Texas.

19 October 2008

BabyBoy's new teeth

I'm in love with his gap teeth.



We took this picture of his three new top teeth this evening. He has been sick all weekend and we finally got him in a good mood to snap a quick photo. This is right before I put eye drops in his eyes and got him all cranky again.

17 October 2008

Crochet your own Obama and McCain finger puppets!




Free patterns for these are available at the Lion Brand Yarn website. Stage your own debate! Make them thumb wrestle! Have fun!

16 October 2008

My new technical blog: Geeky Thought Bubbles

I just started another blog focused on my more technical, geekier interests. Actually, I've just copied over the tech stuff from this blog over to the new one. But all new geeky posts will go there. Check out Geeky Thought Bubbles.

BabyBoy at daycare this morning

He was a little cranky this morning. But so handsome in his 'big boy' clothes.

15 October 2008

Emerging brick after a good rain

San Antonio and 6th streets, Austin, Texas.

12 October 2008

A beautiful October weekend



This was a beautiful weekend here in Austin, TX. The weather has been great. Finally a little bit of relief from the Texas summer heat. My weekend actually started early on Friday. As it turned out, BabyBoy had his flu shot on Wednesday. At 5 p.m. on Thursday, the day care called and said that he had a fever, and needed to be fever-free for 24 hours before he could come back to school. When I picked him up, he was sleeping, and slept for about hour more when we got home. Then after he awoke, I took his temperature three times just to be certain, but he had no fever. Anyways, we had our own day together on Friday. We went on a 5 mile walk (well, BabyBoy slept in the jogging stroller as I walked), we went to eat lunch with D, and then did a little bit of shopping. Saturday and Sunday were also beautiful days, with beautiful weather. We caught up a little bit with house chores. BabyBoy had a great time at the grocery store today. He was all giggles. Then he got to play with grandparents this afternoon, and had a great time. The photo above was taken today, just before grandparents drove back to San Antonio.

09 October 2008

Some thoughts on designing a test framework with Ruby

Here are some of my thoughts after actively working on a test framework in Ruby and scripting and running test scripts for the last couple of months.

Start writing tests first, and then grow your framework. I tried to design a framework before I had a solid idea of what the testing needs were. I had just joined the company, and didn't really understand the use cases and test procedures very well. So, I just made assumptions of what I thought would be good common code and what should be in a "good" test framework. These assumptions came from other test frameworks I had used or designed in the past. I felt like my experience would make up for my lack of product knowledge. In a lot of cases that was true, but I could have delved more into the testing side, instead of just the framework. Sometimes to test something, you just need a very simple script, and a sophisticated framework can just get in the way.

Don't overdesign features before you really need them. For example, I'm thinking of ripping out the logging stuff I implemented, because now it is annoying me. I had designed the test framework so that when you include the test harness class in the test class, a log will be made for any test run. Well, I found out I wasn't really reading the logs too much, I was just relying on the output from Ruby's Test::Unit class. And I hadn't implemented a cleanup mechanism to clear the logs after a certain age was reached. So, I'm constantly typing "rm -f *.log". I think it is wiser to not force the logging in a test class, and have the test developer decide what logging is necessary and the mechanism to do that.

The DRY (Don't Repeat Yourself) concept is great, but don't get too fancy, though, with code reuse and that magical metaprogramming (if you are using a dynamic language like Ruby, as I am). It probably doesn't matter much when you need to quickly crank out tests, since this is just testware, not shippable code. In most cases, I think repeating yourself a couple of times is okay, especially when you are trying to automate as much of your tests by the end of a sprint. But once you get to the magical number of 3, then you should think about your modularity and move your repeated code to a common library.

Don't get hung up about trying to implement tests in only one language. This is probably a good reason to not spend too much time working on a framework, because, you might need a different language or tool to perform a subset of your tests. For example, there are some things that Java is better at than Ruby and vice versa. When it comes to manipulating large amounts of XML, performance-wise, Java would be my choice over Ruby.

08 October 2008

Look who is 9 months old today!

Just after our checkup with the doctor. We all got flu shots and BabyBoy got a blood test.

07 October 2008

Using Ruby and ERB to dynamically create XML files from templates

Here is a simple way to dynamically create XML files from templates. Actually, it could be any type of file. I chose XML format, because I work with plenty of XML at work. And I use this technique in a test setup.

For our example template, here is a very basic XML file, called ERB_example.xml.

<email>
<to><%= $name %></to>
<from><%= $me %></from>
<date><%= Time.now %></date>
<subject><%= $hello %></subject>
On your way home, please pick up the following from the store:
% $list.each do |thing|
* <%= thing %>
% end
<%= $signoff %>
</email>


As you can see, it has the basic elements of an email message, I have tags surrounded by <%= and %>. Anything inside these tags are treated like a Ruby expression and are evaluated. I also have two occurrences of just %. These are treated as the other tags if they are at the start of the line. (Note that I did not indent those lines!) This is useful for us because we cannot nest the <%= and %> tags. (Try it!)

Just to make things easier for this example, I am using global variables for most of these tokens. I also have an expression Time.now which will substitute the date and time. Now to our Ruby script, ERB_example.rb.

require 'rubygems'
require 'erb'

# set up some variables that we want to replace in the template
$hello = "Hola"
$me = "Tu mama"
$name = "Mi'jito"
$list = [ "milk", "eggs", "bread"]
$signoff = "Te quiero mucho."

# method update_tokens takes template_file, expecting globals
# to be set, and will return an updated string with tokens replaced.
# you can either save to a new file, or output to the user some
# other way.
def update_tokens(template_file)
template = ""
open(template_file) {|f|
template = f.to_a.join
}
updated = ERB.new(template, 0, "%<>").result

return updated
end

new_xml=update_tokens(Dir.getwd+"/ERB_example.xml")
puts new_xml


Note that in our third argument to ERB.new, we are telling ERB two things. First, the % says to process any % at the beginning of a line. Second, the <> says to omit any newline for lines beginning with <% and ending with %>.

So, our final output when we run this little script is as follows:

<email>
<to>Mi'jito</to>
<from>Tu mama</from>
<date>Tue Oct 07 14:22:10 -0500 2008</date>
<subject>Hola</subject>
On your way home, please pick up the following from the store:
* milk
* eggs
* bread
Te quiero mucho.
</email>


You can find out more about ERB at the Ruby Standard Library Documentation.

06 October 2008

How to compile and install Ruby on RHEL 4

This is one of those posts where I'm mostly writing this so I can remember how to do it in the future. But maybe it will help someone else, too. I'm not a Unix sysadmin, by any means, but here is what I did to get, compile, and install Ruby on a RHEL 4 system at work. I realized later that I could have found and installed an RPM, but after I started down this path, I wanted to finish it.

First of all, this may seem backwards, but I set these environment variables first. This is because I messed up the first time I tried to install Ruby, so these were left hanging around.

export RUBYLIB=/opt/ruby/lib:/usr/lib/site_ruby
export PATH=$PATH:/opt/ruby:/opt/ruby/bin

Next I downloaded the Ruby source code:

wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz

I unarchived it:

tar -zxvf ruby-1.8.6.tar.gz

I made a symbolic link which will match the paths in the RUBYLIB and PATH environment variables I set up previously. Also, it's just a lot easier to type /opt/ruby instead of /opt/ruby-1.8.6-p287:

ln -s ruby-1.8.6-p287 ruby

Now, we build and install:

cd ruby
./configure
make
make install

I next installed RubyGems. First we download the archive and unpack:

wget http://rubyforge.org/frs/download.php/43985/rubygems-1.3.0.tgz
tar -zxvf rubygems-1.3.0.tgz

Then we run the setup:

cd rubygems-1.3.0
ruby setup.rb

And that is it!

05 October 2008

A fun Sunday at home

D and BabyBoy chill out this afternoon and watch the Phillies beat the Brewers.

BabyBoy later in the evening, just before bath time.

04 October 2008

Cinnamon rolls

D is on a roll....making home made cinnamon rolls this morning!

Mmmmm....delicious!

And BabyBoy is all grins after eating his cereal for breakfast.

03 October 2008

Pizza night

D made pizza from scratch for dinner.




YUM!

01 October 2008

How to print to PDF on Windows for free


One of the nice things that Mac OS X has out of the box is support for PDF. You can easily print to PDF without any other software. Unfortunately, with Windows, that is not the case. There are commercial products available that allow you to print to PDF. But there is another way, a free way to do it. I set this up on my computer at work using the following tutorial: Creating a free PDFWriter using Ghostscript. The only thing that I did differently was to download and use HP's Universal Print Driver.