I went contra dancing with some friends last Friday. I’ve done English country dancing before, but never contra. It’s quite a workout, but really fun. Our friends were kind enough to post this video from the event:
Category: General Interest
-
Building arrays of similar objects in Ruby
I often find myself having to build arrays of similar objects in my tests. For example:
def create_user :some_user end users = [create_user, create_user, create_user]
It seems wasteful to repeat the same method call three times. One solution is to use the #times method to append to an array, like this:
users = [] 3.times { users << create_user }This just doesn't seem very elegant, though. It feels like I should be able to collect the results from each method call with a single line of code. I experimented with the multiplication operator to see if it might be able to do what I wanted, but didn't get far.
Here's one possible solution I came up with:
class Integer def of result = [] times { result << yield } result end end users = 3.of { create_user } # returns [:some_user, :some_user, :some_user]The #of method can now be called on an integer. It uses #times to call the given block three times and appends the result to an array which is then returned. Much more elegant. Another way to achieve this on a single line is:
users = (0..2).to_a.collect { create_user }This doesn't feel as nice to me. It's visually complex and, at first glance, the zero-basing of the range hides the fact that we're collecting three items, not two. The benefit is that no reopening of the Integer class is required.
How would you solve this problem?
-
Is Communism really dead?
I found Misreading the Tea Leaves by J.R. Nyquist to be pretty thought-provoking. Maybe you will too.
-
Bill Gates wants to annoy the whole world with Windows
Yes, it’s true. Bill Gates wants to annoy the whole world with Windows.
-
Wasting time
“Imagine for a moment that someone has established for you a very unusual bank account. Each morning he has agreed to deposit $86,400. At then at the end of each day whatever you have not spent will be forfeited. Would you not be diligent to see to it that every penny of that account was withdrawn and properly spent? Would you allow any of it to expire unredeemed? You have such an account. For God has given you 86,400 precious and irreplaceable seconds in this day. Whatever is not used will expire and can never be reclaimed. Seize each moment therefore and invest it wisely.” — Rick Grubbs
-
And you thought homeschooling was tough?
These people need to seriously rethink their approach to preschool. Why not just teach the kid at home for a year instead of freezing your tail off in line?
-
Trouble purchasing iPod Touch January update
I was initially quite irritated with Apple for choosing to charge existing iPod Touch users like myself a $20 bill to get a hold of their January update. I’m still a bit ticked since it seems quite unfair to punish the early adopters like this, but by last Tuesday I had decided to push past my annoyance and plunk down the $20 for the update.
Now I can’t seem to purchase it for some reason.
When I visit the iTunes store or Apple’s web site and click on the link to buy the update, I get sent to a page with information about the update and a single OK button. I click OK and get sent back to the iTunes store home page. Every. Single. Time.
I’ve called Apple a couple of times on this. They say it’s a bug on their end and that they’re working on it, but they can’t seem to give me an estimated resolution time. Apparently, this problem is only being experienced by a few lucky people, like myself.
Has Apple lost a sale? Possibly. I want to give them my $20, but they just don’t seem to want it that badly. I may opt to use the 1.1.3 jailbreak instead (when it becomes available for the Touch).
And I was really looking forward to using the “official” apps…
-
Locking a nation into permanent childhood
America’s education system is majorly messed up. The disturbing thing is the intentionality with which it’s being destroyed, coupled with the ignorance of most parents to what’s really going on:
… American schooling was taken over, in the late 19th century, by statists enamored of the Prussian compulsion model, aiming to create a docile peasant class by crippling the American intellect — making reading seem real hard, for starters, by replacing the old system in which delighted kids learned to combine the sounds of the Roman letters, with a perverted “whole word” method better suited to decoding hieroglyphics.
If God blesses me with a family, I’ll be homeschooling my kids. I only hope it’s still legal by that time.
-
Fixed bid vs. time and materials
“It’s unwise to pay too much… but it’s worse to pay too little. When you pay too much, you lose a little money… that is all. When you pay too little, you sometimes lose everything, because the thing you bought was incapable of doing the thing it was bought to do. The common law of business balance prohibits paying a little and getting a lot…it can’t be done. If you deal with the lowest bidder it is well to add something for the risk you gain. And if you do that, you will have enough to pay for something better.” — John Ruskin 1819-1890
-
Vacate room when CFL bulb breaks
Anyone else think we’re shooting ourselves in the foot on this one? If the choice is between greater power consumption and mercury poisoning, I think I’ll opt for greater consumption, thanks. The more government tries to solve these problems for us, the worse things get. Here’s a novel idea: why don’t we all just start turning off the lights when we leave the room? I know, I know… shocking concept.