occasionally useful ruby, ubuntu, etc

11Dec/106

Cr-48 Hardware

For those curious exactly how much RAM, HD, and what CPU the Cr-48 has, the chrome://system display is rather helpful. Hit the jump for details.

21Nov/100

Time matcher for RSpec2

I've found myself reusing this matcher a bit for time-sensitive tests, so I thought I'd share it. It allows you to verify that a block took a certain amount of time to execute.

Filed under: ruby Continue reading
29Oct/105

Ruby Monitor Basics, or, How the heck do I synchronize producers/consumers

Have you ever written something like this?

threads = []
threads < < Thread.new { something_slow }
threads << Thread.new { something_really_slow }
threads << Thread.new { go_take_a_coffee_break }
threads.each {|t| t.join}
puts "all done!"

This works fine, but...it's expensive to start up and stop threads (even green ones), and what if you instead used/needed Ruby's queue:

1
2
3
4
5
6
7
8
9
10
11
require "thread"
q = Queue.new
q < < 3 << 10 << 10000 < 2352352
threads = []
10.times do
  threads << Thread.new do 
    num = q.pop
    # marker 1
    puts "#{num}: " + calculate_fibonacci_for(num)
  end
end

For those of you who don't know, Queue is basically a (threadsafe) array that puts the calling thread to sleep if #pop is called on it while it's empty, and wakes it up again when it's not empty.

But how do we know when we're done? You can't call #join on all the threads; they never terminate because they're blocking on q. Here's where monitors come in.

Filed under: ruby Continue reading
25Oct/100

ReReplay: Replay production traffic

Ever wonder if your change is going to slow down the website? "Performance impact will probably be negligible", you might say. Well, now you can know for sure. First, take a slice of your production logs and transform it into a particular format. Then run ReReplay with this snapshot to generate a baseline. Next apply your change, rerun ReReplay (sorry, too many re's?) and measure the difference!

5Sep/100

Easy way to generate “release notes” on GitHub

Assuming you're using tags with your git repository on GitHub, it's rather easy to generate something resembling "release notes"; or at least, a list of descriptions of all changes between two tags. That's pretty much the same thing, right? Anyway, if you go to "/compare/tag1...tag2" under a project on GitHub, it'll show you everything that changed between those two tags. Here's an example: Radiant's changes between 0.9.0 and 0.9.1. Neat, huh? If not used as the actual release notes, it can at least help you remember all that changed between two releases when you handcraft a list yourself.

This feature was announced March 1, 2010, but it's hard to find unless you know you're looking for "compare view" :) . It's also sort of hard to find -- you have to go to the Source tab, then Branch List, then hit the Compare button on a random branch, and then, finally, you can input a start and end tag in the upper right. Easy to find, no?

Filed under: musing No Comments
2Sep/108

Announcing Crow, a path-finding library in Javascript

Over the past few weeks I've been building out a clean and fast path-finding library in Javascript with a particular gaming site in mind, and I'm pretty happy with where it's at right now. If you're interested in at least one of: API design, Google Closure library, Google Closure compiler, or QUnit, then hit the jump for more. In the future, I'll cover Javascript (and object-oriented patterns), path-finding (breadth-first search, Dijkstra's algorithm, and A*), rake, games, and the embedded Sinatra+Bundler.

31Aug/100

How we got here: Web App Stores

The recent sudden popularity in web "app stores" is taking off with a rate normally associated with fads, but in some respects is actually to be expected. Still, it bears an interesting similarity with one of the oldest types of websites that the average consumer has seen: directories.

11Jul/100

Grandparent of Ruby and Java: Eiffel and friends

I'm curious about the effort involved in writing a new programming language, and hence have been doing a little research (including watching Guy Steele's now-famous and amusing Growing a Language lecture). I know I want to target the NekoVM (primarily one of the targets of haxe, for now), but what languages should I base it on? One of the languages I've heard a good deal about about, mainly based on its design-by-contract principles, is Eiffel.

(even if you're not interested in building a new language, learning about programming languages and their design decisions increases our understanding of them and, hopefully, our proficiency with them)

11May/1058

Attaching a sticky (fixed) header/footer to an Android ListView

In my Android app, I have a ListView, and I want to persist a button at the bottom of the page (like how the Gmail app has Archive, Delete, and Older on the View Email screen). Unfortunately, this is not trivial, and many others have tried, but despite those suggestions, I never found something that quite worked correctly. The third article above got me actually pretty close, so without further ado, here's a working solution (images and javascript include after the jump):

Filed under: android Continue reading
6Mar/109

HTML5 Web SQL Database – Intro to Versioning and Migrations

I've been dabbling a bit with Chrome extensions, which have at their disposal HTML5 localStorage and Web SQL Database. And...the web sql database especially is pretty cool. But one thing was bothering me -- if I have a database on the client, how do I maintain the schema? The (simplest) answer is in changeVersion.

Tagged as: , Continue reading