From the category archives:

Uncategorized

“Was this ad supposed to be funny?” is the question that a lot of techies are asking after having seen the first of the new series of Microsoft ads featuring Bill Gates and Jerry Seinfeld. The ad, which sets up both the tone for future commercials and the Bill/Jerry dynamic, could’ve been lifted straight from any number of Seinfeld episodes. In fact, the “Churro? No thanks” exchange is practically a repeat of the “Snapple? No.” exchanges in the episodes The Virgin and The Visa.

It’s a real shame that the ad turned out this way because there’s prior work with Bill and celebrities that is funny and gives Microsoft a warmer, fuzzier image. Here are two of the most notable ones…

Bill and John Heder in a Napoleon Dynamite Spoof

This video was shown at Microsoft’s 2005 Professional Developers Conference, and unlike the ad with Seinfeld, it makes good use of the source material and the guest star, and better still, it’s actually funny. They could’ve easily repurposed this ad or called Jon Heder to shoot some more:

Bill Gates’ Last Day

This one’s not as funny or as clever as the Napoleon Dynamiteone, but it’s still amusing and cute: it’s a video shown at the Consumer Electronics Show earlier this year that purports to be a documentary of Bill’s last full day at Microsoft. This one features a boatload of celebrities: Bono, Hillary Clinton, Bob Costas, Al Gore, Barack Obama, George Clooney, Jay-Z, Matthew McConaughey, Jon Stewart, Steven Spielberg and Brian Williams.


We’ll have to wait ands see if the next Gates/Seinfeld ad is any better, or at least generates more than a mild chuckle. They’ve got nowhere to go but up…

{ 1 comment }

Google Chrome is Now Available for Download!

by Joey deVilla on September 2, 2008

Downloading Google Chrome

I’m downloading Google Chrome as I write this. More later.

{ 0 comments }

Enumerating Enumerable: Enumerable#include?

by Joey deVilla on September 2, 2008

Enumerating Enumerable

Welcome to the eighteenth installment of Enumerating Enumerable!

In this series of articles, I’m going through the methods in Ruby’s Enumerable in alphabetical order, explaining what each does and providing examples. This is my attempt to make better documentation for Ruby’s Enumerable module than Ruby-Doc.org’s.

In this article, I cover the include? method.

In case you missed any of the previous articles, they’re listed and linked below:

  1. all?
  2. any?
  3. collect / map
  4. count
  5. cycle
  6. detect / find
  7. drop
  8. drop_while
  9. each_cons
  10. each_slice
  11. each_with_index
  12. entries / to_a
  13. find_all / select
  14. find_index
  15. first
  16. grep
  17. group_by

Enumerable#include? Quick Summary

Graphic representation of the "include?" method in Ruby's "Enumerable" module.

In the simplest possible terms Does the collection contain an item equal to this one?
Ruby version 1.8 and 1.9
Expects An argument containing the item to search for in the collection.
Returns
  • true if there is at least one item in the collection that is equal (using the == operator) to the argument.
  • false if no item in the collection is equal (using the == operator) to the argument.
RubyDoc.org’s entry Enumerable#include?

Enumerable#include? and Arrays

When used on an array, include? iterates through it, comparing items in the array with the argument using the == operator. If any of these comparisons has a result of true, include? returns true. If you think of arrays as sets, you can think of include? as a set membership test.

Examples

# Here's a list of words (if they seem unfamiliar, go read
# http://en.wikipedia.org/wiki/Zoom_schwartz_profigliano)
words = ["zoom", "schwartz", "profigliano", "butterman"]
=> ["zoom", "schwartz", "profigliano", "butterman"]

# Is "profigliano" in our list of words?
words.include? "profigliano"
=> true

# How about "kwyjibo"?
words.include? "kwyjibo"
=> false

Enumerable#include? and Hashes

include?, when used with a hash, behaves differently than you might expect. You might think that include? would return true if given a two-element array argument that matched an item in the hash, where the first element matched the key and the second element matched the corresponding value.

However, that is not the case. Instead, include? returns true if there is a key in the hash that is equivalent to the given argument when compared with the == operator. In other words, include?, when used with a hash, answers the question “Is there an item in this hash with this key?”

Examples

values = {"zoom" => 1, "schwartz" => 5, "profigliano" => 10, "butterman" => 25}
=> {"zoom"=>1, "schwartz"=>5, "profigliano"=>10, "butterman"=>25}

values.include? "schwartz"
=> true

values.include? ["schwartz", 5]
=> false

values.include? "kwyjibo"
=> false

{ 0 comments }

b5media is a Red Herring Canada Top 50 Finalist

by Joey deVilla on August 26, 2008

Red Herring "Top 50 Canada" badge and b5media logo

b5media, the company where I work and hold the title of “Nerd Wrangler”, is one of the finalists in Red Herring Canada’s “Top 50″ Awards, which is described as…

…celebrating the most innovative and promising companies in Canada. Adding to the success of our yearly North America 100, Europe 100 and Global 100 events, Red Herring Canada will provide an opportunity for the nation’s Top 50 companies to deliver their message to the top VCs and other participants throughout North America and abroad.

The Top 50 will be announced at the Red Herring Canada ‘08 event in Mont Tremblant (near Montreal), which takes place from September 15th through 17th.

{ 0 comments }

I’m on “Future Tense” Tonight

by Joey deVilla on August 26, 2008

John Gordon, host of "Future Tense"On Friday, Jon Gordon from the radio show Future Tense interviewed me about my recent posting here titled Seinfeld and Celebrity Computer Endorsements, which features my comments on Microsoft’s hiring of Jerry Seinfeld as a pitchman and a collection of celebrity computer endorsements. In the interview, which is being broadcast tonight, we talk about whether celebrity endorsements for computers work, as well as some of our favorite celebrity computer advertisements.

Future Tense is broadcast on American Public Media stations. For a schedule of when it’s on, click here.

{ 0 comments }

Security Through Python

by Joey deVilla on August 25, 2008

While this is actually not about computer security nor about the Python programming language (which I’ll cover in some articles soon), I thought my Pythonista readers might find it amusing…

Guy freaking out at seeing two pythons on the dashboard of a car

…for the real story behind this photo, see this article in the Daily Mail.

{ 0 comments }

Even if you saw yesterday’s post about celebrity tech endorsements, do check it again — I’ve been updating it with more ads for computers and videogames featuring celebrities, and I still have to add a few more.

Here’s an 1970s print ad that seems gallows-humor funny today, considering that there are people itching to attack Iran before they develop nuclear weapons. It features the Shah of Iran as a poster boy for a campaign encouraging more nuclear power plants in the U.S.:

Print ad: "Guess who's building nuclear power plants", featuring the Shah of Iran

Here’s the text of the ad:

Guess Who’s Building Nuclear Power Plants

The Shah of Iran is sitting on top of the largest reservoirs of oil in the world.

Yet he’s building two nuclear plans and planning two more to provide electricity for his country.

He knows the oil is running out — and time with it.

Be he wouldn’t build the plants now if he doubted their safety. He’d wait. As many Americans want to do.

The Shah knows that nuclear energy is not only economical, it has enjoyed a remarkable 30-year saftey record. A record that was good enough for the citizens of Plymouth, Massachusetts, too. They’ve approved their second nuclear plant by a vote of almost 4 to 1. Which shows you that you don’t have to go as far as Iran for an endorsement of nuclear power.

For more about Iran’s history with nuclear power (and how it intertwines with U.S. foreign policy), see this article at Foreign Policy in Focus.

{ 2 comments }

Enumerating Enumerable: Enumerable#grep

by Joey deVilla on August 21, 2008

Enumerating Enumerable

Once again, it’s Enumerating Enumerable time! This is the latest in my series of articles where I set out to make better documentation for Ruby’s Enumerable module than Ruby-Doc.org’s. In this installment, I cover the grep method.

In case you missed any of the previous articles, they’re listed and linked below:

  1. all?
  2. any?
  3. collect / map
  4. count
  5. cycle
  6. detect / find
  7. drop
  8. drop_while
  9. each_cons
  10. each_slice
  11. each_with_index
  12. entries / to_a
  13. find_all / select
  14. find_index
  15. first

Enumerable#first Quick Summary

Graphic representation of the "grep" method in Ruby's "Enumerable" module

In the simplest possible terms Which items in the collection are a === match for a given value?
Ruby version 1.8 and 1.9
Expects
  • An argument against which every object in the collection will be compared using the === operator.
  • (Optional) A block to be used in a map operation on the resulting array.
Returns
  • If no block is given, an array containing the items in the collection that were a === for the given argument.
  • If a block is given, an array containing the items in the collection that were a === for the given argument, which is then mapped using the block.
RubyDoc.org’s entry Enumerable#grep

Enumerable#grep, Regular Expressions and Arrays

The grep method’s name implies regular expressions, and that’s one of its uses. When given a regular expression as an argument and used without a block, grep returns an array containing the items in the original array that match the given regular expression.

# Here's a list of countries, some of them with "stan" in their names.
#
# I'm including Stan Lee, creator of many wonderful superhero comics simply because
# he's cool enough to be his own country.
countries = ["Afghanistan", "Burkina Faso", "Kazakhstan", "France", "Tajikistan",
"Iceland", "Uzbekistan", "Australia", "Stan Lee"]
=> ["Afghanistan", "Burkina Faso", "Kazakhstan", "France", "Tajikistan",
"Iceland", "Uzbekistan", "Australia", "Stan Lee"]

# Which countries have the string "stan" in their names?
countries.grep(/stan/)
=> ["Afghanistan", "Kazakhstan", "Tajikistan", "Uzbekistan"]

# Note that "Stan Lee" wasn't included in that list. "Stan" and "stan" aren't the
# same thing, but that's easy to fix:
countries.grep(/[S|s]tan/)
=> ["Afghanistan", "Kazakhstan", "Tajikistan", "Uzbekistan", "Stan Lee"]

When a block is used with grep, the contents of the result array are passed through the block and the resulting array is returned. Think of it as grep followed by a collect/map operation.

# Let's get a look at those countries with "Stan" and "stan" in their names again:
countries.grep(/[S|s]tan/)
=> ["Afghanistan", "Kazakhstan", "Tajikistan", "Uzbekistan", "Stan Lee"]

# Let's get the lengths of the names of those countries:
countries.grep(/[S|s]tan/) {|country| country.length}
=> [11, 10, 10, 10, 8]

# It's a slightly shorter version of this:
countries.grep(/[S|s]tan/).map {|country| country.length}
=> [11, 10, 10, 10, 8]

# This time, let's find all the "stans" and uppercase them
countries.grep(/[S|s]tan/) {|country| country.upcase}
=> ["AFGHANISTAN", "KAZAKHSTAN", "TAJIKISTAN", "UZBEKISTAN", "STAN LEE"]

# And here's the version that uses map:
countries.grep(/[S|s]tan/).map {|country| country.upcase}
=> ["AFGHANISTAN", "KAZAKHSTAN", "TAJIKISTAN", "UZBEKISTAN", "STAN LEE"]

What Enumerable#grep Really Does: The === Operator

Here’s grep’s secret: what it actually does is take each item in the array, compares it against the given argument using Ruby’s === (the “triple equals”) operator and returns an array of those items in the original array for which the comparison returns true.

For regular expressions, the === operator is grep-like. The expression r === s operator returns true if there is a match for regular expression r in string s.

Different classes implement === differently. For example, in the Range class, === is used to see if an item is within the range. The expression r === x returns true if x is in range r. Here’s grep in action when its argument is a range:

# These are the years when the band Radiohead released an album
radiohead_album_years = [1993, 1995, 1997, 2000, 2003, 2007]
=> [1993, 1995, 1997, 2000, 2003, 2007]

# And these are the years when Radiohead released an album between 1996 and
# 2002 inclusive
radiohead_album_years.grep((1996..2002))
=> [1997, 2000]

Generally speaking, collection.grep(thing_to_compare) compares thing_to_compare with each item in collection using the === operator as defined for thing_to_compare’s class. It returns an array of those items in the original array for which the comparison returned true.

Don’t forget the extra processing — a map operation — comes “free” if you provide grep with a block:

radiohead_album_years = [1993, 1995, 1997, 2000, 2003, 2007]
=> [1993, 1995, 1997, 2000, 2003, 2007]

# Adding a block performs a map operation on grep's initial results
radiohead_album_years.grep((1996..2002)) {|year| year % 2 == 1 ? "odd" : "even" }
=> ["odd", "even"]

Enumerable#grep and Hashes

I’ll put it simply: Enumerable#grep isn’t terribly useful with hashes. Like most methods of Enumerable, when applied to a hash, grep, as it iterates through the hash, converts each key-value pair into a two-element array where the first element is the key and the second element is the corresponding value.

As I mentioned earlier, grep uses the === operator to do its comparison, and for arrays, === returns true only when comparing identical arrays:

# Identical arrays
[1, 2] === [1, 2]
=> true

# How about the first array as a subset of the second?
[1] === [1, 2]
=> false

# How about the first array as a superset of the second?
[1, 2, 3] === [1, 2]
=> false

# How about one array as a permutation of the other?
[2, 1] === [1, 2]
=> false

The practical upshot of all this is that for hashes, grep will return the empty array [] for most arguments, with the notable exception of an argument that is a two-dimensional array that corresponds to one of the key-value pairs in the hash.

That was a bit wordy, but an example should clear things right up:

# These are countries and their total areas (not counting outside territories)
# in square kilometres.
total_country_areas = {"Afghanistan"  => 647_500,
                       "Burkina Faso" => 274_200,
                       "Kazakhstan"   => 2_717_300,
                       "France"       => 547_030}
=> {"Afghanistan"=>647500, "Burkina Faso"=>274200, "Kazakhstan"=>2717300, "France"=>547030}

# Is there a '"Burkina Faso" => 274200' item in the hash?
total_country_areas.grep(["Burkina Faso", 274_200])
=> [["Burkina Faso", 274200]]

# That worked because the array argument we provided was an exact match
# for one of the items in the hash when it is converted into an array.

# Is there a '"Burkina Faso" => 0' item in the hash?
total_country_areas.grep(["Burkina Faso", 0])
=> []

# That didn't work because the array argument didn't correspond to any of the items
# in the hash.

Making Hashes grep-able

If you need to find which keys in a hatch pattern-match a given value, use the Hash#keys method (which returns an array of the hash’s keys) and grep that:

# Again with the countries and the areas...
total_country_areas = {"Afghanistan"  => 647_500,
                       "Burkina Faso" => 274_200,
                       "Kazakhstan"   => 2_717_300,
                       "France"       => 547_030}
=> {"Afghanistan"=>647500, "Burkina Faso"=>274200, "Kazakhstan"=>2717300, "France"=>547030}

# Which ones are the "stans"?
total_country_areas.keys.grep(/stan/)
=> ["Afghanistan", "Kazakhstan"]

If you need to-find which values in a hatch pattern-match a given value, use the Hash#values method (which returns an array of the hash’s values) and grep that:

# Of the countries' total areas, which the ones between
# 500,000 and 1 million square km?
total_country_areas.values.grep((500_000..1_000_000))
=> [647500, 547030]

What if you want to find key-value pairs where either the key or the value is a === match for a given argument? There’s a way to do that, and I’ll cover it when we get to the Enumerable#inject method. It’ll be soon, I promise!

{ 0 comments }

M-Audio Axiom 25 USB MIDI keyboard
My toy: M-Audio Axiom 25 USB MIDI keyboard

For my 40th birthday, the Ginger Ninja got me something I’d had my eye on for some time: a USB MIDI keyboard, specifically an M-Audio Axiom 25, a nice little unit with a lot of features. Prior to my picking up the accordion and getting the “Accordion Guy” nickname, I was a synth player for a good long time. I’ve been meaning to get back into it.

I still have a couple of old hardware synths: a Korg Wavestation A/D (a rackmount unit version of the Korg Wavestation) from my days at Crazy Go Nuts University and a Korg Poly-800 that my friend Steph gave to me when she moved out of town.

My last experience was software synths wasn’t all that hot: it was in the late 1990s, when computers and networking were a great deal slower. Software synths felt very “laggy” in comparison to my good ol’ reliable hardware, and after noodling with them for a while, I decided that I’d give technology some time to play catch-up. That time has come, and I’d like to ask any of you who are familiar with this stuff: what are your favorite software synths, samplers and sound modules?

I’m looking for a couple of things in software form:

  • A nice, decent general purpose synth/sampler. I expect I’ll be doing more sequencing than live performance, but you never know…
  • A “groove builder” or “Groovebox” in the spirit of the Roland MC-303

I’m currently on a PC laptop (running Ubuntu and when absolutely necessary, Vista), but I expect to buy a Macbook Pro sometime in the near future. I’d like to hear about what’s available for any platform. Let me know in the comments!

{ 2 comments }

My Stack of Old Computer Books

by Joey deVilla on August 16, 2008

While cleaning out my home office, I found a box books that I’ve been hanging on to for historical purposes and sentimental reasons.

First, this collection of Apple ][ manuals, back from when I had my first computer, an Apple //e. These manuals came with the original apple ][; my //e manuals must be kicking around somewhere...

Apple ][ Manuals

And from my university days, these books: the Adele Goldberg Smalltalk-80 series, Computer Systems in Business, which is rather quaint when read with today’s eyes, and Inside Macintosh from the System 7/8 era:

Smalltalk-80 books, "Computer Systems in Business", Inside Macintosh books

I know I’ve got Lubomir Bic’s The Logical Design of Operating Systems — from which I learned concurrent programming — stashed away, but I can’t seem to find it at the moment.

{ 0 comments }