The big dummy moment and first remote pairing

May 19, 2009 at 8:47 pm (Java, Javascript, Ruby, Week 9) (, , , , , , , , )

This morning I finished up most of a task from our biggest story, with some pointers from Micah. The big dummy moment came at the end of the morning, when I spent about an hour debugging why Javascript wasn’t working properly in our customized Webkit browser, and after going through everything I could think of, I realized that the browser had cached the Javascript file! Ack. So, my choices were to figure out where the cache was and clear it, or to do what Rails has always done for me behind the scenes to prevent caching: append a question mark and a big number to the filename. We’re using Sinatra, so I wrote a simple helper that does the latter:

def no_cache
"?#{Time.now.to_i}"
end

Pretty simple, but I’m not sure I like the way it looks tacked onto the end of the filename in the Erb templates; that may need to change to take a parameter…

I spent a little time in the afternoon working on a JRuby bug that the JRuby team posted on their Twitter feed. The problem was with Array#pack, which I’d never used before (and quite honestly, still don’t entirely understand). It takes a formatting string and packs an array into a string. There was a problem when the asterisk (*) was used in a format string like “A4N*” – it’s supposed to take all the rest of the parameters from the string, but it was taking too few. I tracked it down to a change in value of a local variable (listSize). It was hard to spot, because I wouldn’t have expected the list size to change, so I wasn’t looking for that. Lots of System.out.println’s and compiling ensued. It really gave me an appreciation for Ruby’s interpreted nature. I’m sure there’s a way I could’ve streamlined things, but it was taking me 30 seconds to build the project each time, which is an eternity when you’re just debugging and adding print statements (and especially if you’re not too sure of what you’re looking for).

Micah and I did some remote pairing in the late afternoon, which I’d never done. We used iChat, which was really pretty awesome. We had some problems with audio volume and crashy programs, but all in all, I think it was pretty successful. Micah came up with a new data structure to eliminate some network traffic in our application, and we implemented it, simplifying code and adding a feature along the way. This was code I hadn’t seen before, but it felt a bit easier to get around – partly because it’s just simpler, and (hopefully) partly because I’m getting better.

Advertisements

Permalink Leave a Comment

Cleaning XHTML & jarring gems

May 11, 2009 at 9:30 pm (Java, Limelight, Ruby, Week 8) (, , , , )

Back to my beloved XHTML 1.0 Strict and CSS today. I took some code that came from a client as a quick MS Word-generated web page, grabbed the important things, and deleted. And deleted. And deleted. Always a great feeling to get rid of redundancy. Code like this:

<tr>
<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="#FFFFFF">Some Text</td>
<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;</td>
<td bgcolor="#FFFFFF">Some More Text</td>
<td bgcolor="#FFFFFF">&nbsp;&nbsp;&nbsp;</td>
</tr>

makes me want to laugh and cry at the same time. Maybe it should start its own Broadway musical. At any rate, it’s a bad laughing and a bad crying, so it had to be fixed.

I got to check out Sinatra a little bit in the process, which was pretty cool. It took me a little bit to figure how to get Sinatra serving up images and stylesheets, but it’s very clear once you know!

set :public, File.dirname(__FILE__) + "/views"
set :views, File.dirname(__FILE__) + "/views"

Public and Views here have similarly-named analogues in Rails. They’re basically what you’d expect.

Micah, Doug, and I worked some more on jarring up gems, and despite some current limitations, we now have a great start on an idea for distribution. If you’re looking for answers on how to do it, check out Nick Sieger’s blog, the best source we’ve found on the topic. Be sure you know what commands and options you’re using, and how they relate to gem directory structure. I had a lot of trouble understanding how gem directories are laid out, and how that related to the jar directory structure, but now I have a good basic idea.

On an unrelated note, if you walk outside real quick to pet the cute new puppy next door, it’s great that you remembered to take your jacket, but it would be best to bring at least one of the following, since you locked the door on the way out: (1) keys, (2) phone, or (3) wallet with ID and spare key. This will avoid embarrassing encounters with neighbors you hadn’t met (although this is one good way to meet people). Not that it happened to me… just sayin’.

Permalink Leave a Comment