“He’s not dead, he’s pining for the fjords”

Turns out that Monty Python’s Dead Parrot sketch wasn’t really groundbreaking. For it’s time, maybe. But it turns out that there’s a similar joke from the 4th century in Greece.

…a joke where a man complains that a slave he was sold had died.

“When he was with me, he never did any such thing!” is the reply.

I still love ’em, even if they were beat to the punch line by about 1500 years. Nudge nudge, wink wink, know what I mean?

Programming Visas, and effective regulation

I read an article on H-1B visas in the Harvard Business Review, and there was an interesting point made that I wanted to share.

Multinationals, desperate to fill technical positions, have been seeking alternatives to the use of H-1Bs. A solution that’s growing in popularity is intracompany transfer visas, which allow a firm to bring an unlimited number of foreign employees into the United States. But employees are eligible only after they have worked for the company for a year. So a multinational might, for example, assign a new hire to spend 12 months working in a country with looser immigration rules before bringing him or her to the United States.

The article then goes on to discuss how companies are also trying to simply avoid basing workers in the US at all. I suspect that — long term — this is not something we should want to encourage.

I thought this was interesting because it’s a clear demonstration of how companies will find a way around regulations, and how carefully regulation has to be designed so that is effective.

Well, that’s nice.

If you’ve ever lost a cell phone, you know how much of a pain in the ass it can be. I’ve definitely lost and damaged phones. Just ask Dan.

I was looking at some papers from a credit card company I use, and realized that they will reimburse me if my phone is lost or stolen.

I wanted to point this out, because your credit card companies might offer this too.

One other thing, if you spend a lot on phones & service, you might be interested in the same card I have.They give you 10% back on phone-related stuff.

Gregg’s “Speeding up Ruby, without the Rails” Presentation

Gregg’s “Speeding up Ruby, without the Rails” Presentation

He points out that the C library stuff is going to cause blocking, because Ruby’s threading manager doesn’t know when it can stop execution. He demos this with mysqlplus, showing 10 queries with the blocking driver, and then showing mysqlplus which is the non-blocking driver. 10x speedup.

He points out dbslayer, which sits between processes and MySQL, and passes JSON out to the processes.

Starling (which uses memcached) is a good tool for job queueing. Looks like it sits on a single server, and serves up jobs when requested. He demoed putting integers into the job stack, could we put whole objects into the stack?

“What if I can’t find a C library to do what I want?” — use Ruby Inline. It lets you embed C code *directly* into Ruby.

Also, he is talking about ruby-prof, which is for profiling Ruby code.

gem install ruby-prof

Very nice stuff, but interpreting the output definitely requires some knowledge. One neat trick is that if you

require ‘ruby-prof’

You can start and stop the profiling so that you only get data from the parts of the code you’re interested in. Also, with this technique, you can easily output HTML formatted and linked code.

Interesting optimizing trick

“#{@var1} #{@var2}”

is faster than

@var + ” ” + @var2

because method calls are expensive, and the plus signs are method calls.

Another pro-tip: if you’re doing a switch-case, put the most common option at the top of the list — it cuts down on the number of compares that it will take to find the desired option.

In Rails 2.2, there’s a new function called “memoize”, which will automatically handle memoizing, so you don’t have to do a

@result ||=

Don't use .nil? calls, because method calls are slow.

if !value

or better

unless value

are better choices.

a, b = b, a # Nice trick for swapping two values

Link love for Gregg: http://www.envycasts.com His presentation style is excellent, and I guarantee you will learn at least one thing you didn't know before.

http://www.railsenvy.com/rubyconf/ This link has more info from his presentation, and source material

RubyConf 2008 Keynote by Matsumoto

Thursday AM Keynote by Matz

This is Matz: http://en.wikipedia.org/wiki/Yukihiro_Matsumoto

He’s talking about his love of languages, and why he got into Ruby.

He’s addressing some of the criticisms, that it’s slow, poorly implemented, embedding issues…he says the list of complaints goes on forever.

But, now he’s talking about why is Ruby good. He says people say it’s enjoyable, that Ruby made programming fun again.

He says he got into BASIC in 1980, and is talking about his problems with it. He says that one thing was the lack of being able to define data types. Everything is predefined, and you can’t change much.

He is talking a bit about LISP, and says some good things about it. He then complains about the parentheses in LISP, then puts up a slide that just says “No.”

He says he likes the aristocracy, as long as he is in power. BASIC gives you no power, LISP gives you full power. But, the problem is that at both ends of the spectrum, we lose popularity. It’s all about balance. You don’t want to go off the cliff of power with LISP, but you want to be able to be near the edge of the cliff — where BASIC isn’t.

He’s talking about why people choose Ruby. When he asks how many people choose Ruby because of Rails, about 60-70% of the room raises their hand. Matz points out that Rails is basically just a DSL for turning Ruby into a web language. He also points out that they are not at RailsConf, they are at RubyConf. This gets a laugh.

Again, talking about LISP, he says it’s a good DSL.

“There are under one million professional Ruby developers now, and we’re projecting there will be four million plus by 2013” — Mark Driver, Gartner analyst

Matz says “The future is bright…too bright maybe. Beware commercial success” He says, right now, we have the community and enthusiasm. In the coming years, we’ll have more money and more job titles. With these resources, come better implementations of Ruby. He says some of these are here now, but there will be more to make Ruby faster, more feature rich, and providing more satisfaction to us, the developers. He also says one of the great things will be all the new developers who are coming to Ruby, and he says “Welcome them, nourish them”. He says there are people who learn Ruby as a first language, and they go on to become great programmers. [Tim: I wonder what happens to people who start in Ruby, and then see C++]

He says he loves us all.

Biscuts, footballs, and a secret.

I’m sure everyone has seen pop culture references to the “nuclear football”, a.k.a. the briefcase kept near the U.S. President that would be used if an emergency nuclear attack were required.

I was thinking about security this morning — codes and keys. Maybe it’s all the political discussion lately, but my mind went to the nuclear football, and the security involved. There’s the obvious large-and-armed-guy handcuffed to the briefcase (which isn’t true, mind you — it’s a small black cable). Obviously I have no special experience in this area, so this is clearly all speculation based on some Googling.

Turns out there’s an interesting amount of information on this topic. Everyone’s favorite source, Wikipedia, has a few interesting articles. There’s one discussing the nuclear football (which actually does not contain codes); the “biscuit” (which does contain a code, but not a launch code); and the security clearance required for the guy who carries the football — Yankee White.

The government is often lampooned as incompetent. But, there’s a few things that they do quite well. For instance, pop culture talks about the “nuclear football” which contains launch codes. It doesn’t. And if you think about it, it wouldn’t make sense to carry actual launch codes. Those are just some ones and zeros that probably get carried along a physical cable to the missiles.

The football is actually a very nice briefcase, filled with some sheets of paper with response plans, a really good cell phone (ok, ok, secure satellite phone), and a few other useful goodies. Hopefully a Snickers, too. You don’t want the President making important decisions on an empty stomach, do you?

Instead of the briefcase containing codes, the code involved is physically kept by the President. Carter kept it in his jacket. Bush Sr. kept it in his wallet. (Side thought: Presidents carry wallets? For their cash?). Also, it’s not a *launch code*. It’s an identification code — a way to verify that the voice ordering a launch on the phone is actually the President. Apparently the last 4 digits of their social security number, along with their mother’s maiden name, wasn’t good enough.

The code is changed daily, and is issued by the National Security Agency. Which brings me to the point that started all of this. What do the codes look like?

In cryptography, you want insane combinations of numbers, letters, and symbols (“Why do cryptography experts get excited about prime numbers?“). But, this code has to be easily spoken via phone. No doubt, you’d like a certain about of uniqueness. Also, it should be something that could be understood when spoken over low-quality audio. You never know when those sat phones will get scratchy-sounding (“I can’t hear you! I’m in a tunnel!”).

Of course, it’s probably safe to say that with Bush Jr, the codes are chosen via a top secret, customized See ‘n Say.

So, we’ve got our requirements list:

  • able to be generated daily
  • robust sounding (can be understood over a bad satellite connection, if needed)
  • easily spoken via phone (not containing symbols, “QzE#j&^b%%”)
  • unique, unmistakable (unlikely to be accidentally spoken)
  • fit on a card (I’m thinking credit card-size)

I personally suspect the codes come in the form of some NSA-level Mad Libs. That is to say, they are probably syntactically valid, interpretable English, but otherwise nonsense. Short sentences that have no real meaning, like

“Three pigs post drywall notes”

“Violet books have hunted chocolate rain”

Codes of this form have the advantage that they can be question-responsed with normal ideas. “I’m sorry, how many pigs were there?” “What color books?”. These are good questions, much easier than asking “What was the fifth letter?” for a code of “5X7b9lOc”

No one will ever accidentally say these codes. Imagine the confusion if a code were “I’d like a bacon cheeseburger”.

So, that ends my thought experiment for the day. Feel free to share your thoughts in the comments.

Barack said WHAT?

OK, this is going to be straight to the point.

I got an email from my father this morning, asking me to verify it. It made some amazing claims about Obama, and I couldn’t resist. It was such a shocking bunch of claims, that I decided to write up a reply, and send it to everyone who had an email address listed on the chain. I’ve included the main content of the email I received, as well as my reply. I encourage you to pass this around, I hope more people find this and read it.

Subject:  Wow, if you want to read something that will scare your socks off, read this in its entirety!

Perhaps there are SOME out there who are beginning to get ‘the picture’.  The following is a narrative taken from Sunday Morning’s televised ‘Meet The Press’. and the author is employed by none other than the Washington Post!!  Yeah……the Washington Post of New York and Los Angeles Times fame!!  Must say that I’m dually impressed………………

From Sunday’s Televised ‘Meet the Press’ Senator Obama was asked

about his stance on the American Flag.  Obama Explains National Anthem Stance Sun, 07 Sept. 2008 11:48:04 EST, General Bill Ginn’ USAF (ret.) asked Obama to explain why he doesn’t  follow protocol when the National Anthem is played.

The General also stated to the Senator that according to the United States Code,

Title 36, Chapter 10, Sec. 171… During rendition of the national anthem when the flag is displayed, all present except those in uniform are expected to stand at attention facing the flag with the right hand over the heart. At the very least, ‘Stand and Face It’

Senator Obama Live on Sunday states, ‘As I’ve said about the flag pin, I don’t want to be perceived as taking sides, Obama said. ‘There are a lot of people in the world to whom the American flag is a symbol of oppression. And the anthem itself conveys a war-like message. You know, the bombs bursting in air and all. It should be swapped for something less parochial and less bellicose. I like the song ‘I’d Like To Teach the World To Sing.’ If that were our anthem, then I might salute it.’We should consider to reinvent our National Anthem as well as to redesign our Flag to better offer our enemies hope and love. It’s my intention, if elected, to disarm America to the level of acceptance to our Middle East Brethren. If we as a Nation of warring people, should conduct ourselves as the nations of Islam, whereas peace prevails. Perhaps a state or period of mutual concord between our governments. When I become President, I will seek a pact or agreement to end hostilities between those who have been at war or in a state of enmity, and a freedom from disquieting oppressive thoughts. We as a Nation have placed upon the nations of Islam an unfair injustice. My wife disrespects the Flag for many personal reasons. Together she and I have attended several flag burning ceremonies in the past, many years ago. She has her views and I have mine’. Of course now, I have found myself about to become the President of the United States and I have put aside my hatred. I will use my power to bring CHANGE to this Nation, and offer the people a new path of hope. My wife and I look forward to becoming our Country’s First Family. Indeed, CHANGE is about to overwhelm the United States of America.

WHAAAAAAAT the Hell !!!

Yes, ladies and gentlemen, you heard it right. This could possibly be our next President.

I, for one, am speechless.

And, my reply

Hello,

My name is Tim Rosenblatt, and although you probably don’t know me, I received an email about Barack Obama which had your email address listed on it. So, you’ve probably recently seen an email about Barack having appeared on Meet the Press, and discussing why he doesn’t pledge allegiance to the flag, why he thinks our National Anthem should change, and a few other shocking comments.

My father sent this email to me, asking me about it. I am personally a Barack supporter, but after reading it, I thought the claims were outrageous. Since I think everyone should be given a fair shot, I looked into it.

This original email seems to have been sent on Oct 9, and talks about “last Sunday”, which I can only assume is Oct 5. It also mentions Sept 7. Obama wasn’t on that show on either of those dates. Neither was Bill Ginn.

According to the website for Meet the Press (the following links), the last time Obama was on Meet the Press was July 27, 2008. Bill Ginn wasn’t on the show. You can even read the transcripts of all of their shows with these links.

http://www.msnbc.msn.com/id/8987534/
http://www.msnbc.msn.com/id/3032608/
http://www.msnbc.msn.com/id/25872804/ – The full transcript of Barack’s last appearance on Meet the Press

I’m sending this out because I think that making a good decision is hard enough with all of the truthful information out there. We don’t need fake rumors clogging up our brains.

Also, I know we’re close to Election Day, but I’d like to ask you to send me any other claims you’ve gotten in your email. I’d appreciate the opportunity to look at some of these emails and find out if there’s any truth to them.

Here’s the extra links.

http://www.truthorfiction.com/rumors/o/obama-pin.htm – This is a very similar email to the one you’ve received
http://fightthesmears.com/ – An official campaign site set up to deal with rumors
http://www.truthorfiction.com/rumors/o/obamalinks.htm – A large collection of Barack rumors

Thanks for taking your time to give this a second thought.

— Tim

Please pass this around. I think most people would rather have their opinions lose to the truth, than to win with lies.

Max Payne and “know thy audience”

I saw Max Payne last night. Overall, it’s an okay movie. It wasn’t boring, it wasn’t slow, and we stayed entertained the whole time. Cool CGI and camera stuff also. But, there was too much that broke the suspension of disbelief for us. I mostly think it was the dialog and the fact that it was a video game movie.

A “video game movie” is one that’s clearly made for fans of the game. I think directors are still learning how to turn a video game into a good movie, in the same way that they have learned how to turn books into movies. If you ever want to talk about a video game movie, or movie production, I’m always interested in that stuff. But that’s not my point here.

Like I said, a video game movie is made for the fans. That is to say, other people who play video games. I’d say, based on my personal knowledge and experience, that video game fans (and are likely to go to a Max Payne movie), also tend to like the Mythbusters. I do.
In case you don’t accept that assumption, you should know that last week’s Mythbusters had a “special sneak preview” Max Payne trailer during the episode. I did not see this trailer advertised during other shows. Somehow Rachel Ray’s audience doesn’t seem like the Max Payne type. So, clearly the marketing staff for the movie and Discovery Channel agree that people who are watching Max Payne have probably seen a few Mythbusters episodes.

The reason I bring this up is because in one scene, Max is underwater in a river, and there are handguns being fired at him. He’s probably 10 feet under, and the bullets are whizzing by him. In fact, it’s the exact same situation that the Mythbusters tested several years ago, and busted. But it’s in this movie.

Now, despite having written several paragraphs about this, I swear I’m not a foaming-at-the-mouth movie nerd. I’m not going to scream about it not being realistic. It was a cool looking shot, and the movie was a good way to spend 90 minutes. But it was another moment where something in my brain was awkward moment that helped break the suspension of disbelief that movie makers try so hard to achieve.

I feel like there’s some Seth Godin-esque point to be made here. When you do something for an audience, be sure to think about their perspective.

Arduino Follow-up

As a follow-up to yesterday’s post about Matt Williams’s presentation on Ruby and Arduino, here are some videos, slides, and notes from the ORUG site.

You absolutely must check this out. The field of robotics is going to play such a massive role in all of our lives over the next few years, and this is the ground floor.

*Going up?*

Physical Computing with Ruby and Arduino

Just got back from this month’s ORUG, where Matthew Williams gave a presentation on using Ruby to control an Arduino. Matt is a very natural speaker, and the presentation was great. He even demoed a bartending robot he built, which should be featured on Make very soon.

I took notes during the presentation, and they are as follows, with links where possible.


Matthew Williams
Physical Computing with Ruby and Arduino

Arduino is an open-source board

There’s Bluetooth Arduino boards

There’s an Arduino board that was developed in a circular shape. People have combined this with conductive thread and sewn it into clothing. Someone even integrated this with some LEDs into their clothing and made a shirt with turn signals for biking.

Matt showed a video of a Wii nunchuck integrated with an Arduino, hooked up to some servos, and made a robotic puppet that works just by moving the nunchuck (not the control stick, just the accelerometer motion).

There’s also a YouTube video with someone who built a 1-wheel Segway-esque skateboard. Matt claims there are only about 50 lines of code controlling this device.

So, onto the Ruby Arduino Framework.
http://rad.rubyforge.org/ << outdated
http://github.com/atduskgreg/rad/ << more up to date

Matt says that the Arduino Google Group is fantastic.

[Tim: The Arduino IDE looks a *lot* like the Processing IDE (the Java-based graphics language).]

RubyToC – Ruby To C project; converts your Ruby code into C++, then compile it into Arduino bytecode. Then, there are Rake tasks which will load it onto the board for you. Most — but not all — of the Arduino API has been ported to Ruby.

RAD Methods
input_pin(s)
output_pin(s)
digitalWrite | digitalRead
analogWrite | analogRead
serial_print | serial_read

He mentions a slick trick for controlling the 7-segment LED displays. Since there’s 7 segments, you need to set 7 values separately, OR just create an array of those, and set them all with a single assignment.

Coming soon to RAD framework:

  • Testing
  • Arduino Simulator (for testing)
  • Better RubyToC support (there’s a few hacks required because ToC isn’t perfect)
  • More “out of the box” support
    • LCDs
    • OLED displays

Arduino “shields”
Shields are boards that can be plugged directly on top of the Arduino that add major new functionality.

Where to buy? Only $34.95 at
http://www.sparkfun.com
http://www.makezine.com (Matt strongly recommends subscribing to Make, says the dead trees copy is excellent)

Cheaper versions are available, but they either have components removed, or you must assemble it yourself

Make published a “get started with Arduino” kit, about $80, includes project info, the Arduino, extra parts. Most of the parts required for the project are included in the kit.

Barduino – DRINK MIXING ROBOT (created by Matt, who is clearly demonstrating his aptitude as a proper geek)
He used windshield washer pumps, $9/each

Matt created a DSL for describing drinks

drink ‘Screwdriver’ do
serve_in ‘Highball Glass’
ingredients do
2.ounces :vodka
5.ounces :orange_juice
end
end

Matt mentioned a hack, some functions that accept only one param will get converted (by RubyToC) to functions that accept none, so, the following line fixes it

def dispense(pump)
foo = pump + 0 /* This is the fix */

end

For more Ruby Arduino…

RubyConf 2008, Friday, 10:25 – 11:05, Room 3
Greg Borenstein — author of the Ruby Arduino framework — is presenting

Questions:

Can you “brick” an Arduino?
Not via code, but you could put too much power into it and fry it. Matt thinks there’s a little surge protection on it.

Can you sync Arduinos?
He’s seen something like it, and thinks that the serial comm lines would make it fairly easy to do.