Here’s how to add your .pem keyfile to your \$KNOWN_HOSTS so that you never have to rely on being in the correct directory in order to get to AWS with SSH.

``mv keyfile.pem ~/.ssh``

Then type:

``ssh-add ~/.ssh/keyfile.pem``

And now you’re able to easily connect without that long “-i filename” blah blah blah command. Just type:

``ssh <<username>>@<<ec2-dns-info>>.amazonaws.com``

# 3 simple tricks to make learning recursion simple

Recursion is a concept that can be made easier if you have an easy way to think about it, and what it is you’re actually doing. For this discussion, I’ll be considering the Fibonacci function, which returns a number that is the result of adding the two previous fibonacci numbers. This function is bound by zero, so starting at zero you’ll get:

``````f(n) = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...
``````

Here’s what it looks like:

``````var fibberfunk = function(n){
if (n > 2) {
return fibberfunk(n-1) + fibberfunk(n-2);
} else {
return n;
}
};
``````

## 1. It’s turtles all the way down… until you’re at the base:

A recursive solution is suitable for the types of problems that require you to support your next result with the outcomes of previous invocations of your function. Like the old story of what supports the flat earth, recursion can go on and on indefinitely. Unlike the fable, however, we must have a base case or our recursions will fall apart. At the base case, your recursion stops recursing and finally begins to really operate. So you always need to make sure that you have a “base case” to stop the function from depending on itself for any more arguments. In the Fibonacci example, the base case is contained in the `else` statement: When `n <= 2 return n`.

By returning a value which doesn’t require any further code execution, you enable the recusion to stop. Your base case is the first solution that your code will reach, and it’s the result which will support the final results. It’s often easiest to think of the base case as the bottom, but that won’t always be true.

## 2. Always send flowers (unless you don’t have to):

In life, flowers serve the function of reminding the recipient who sent them. (Yes, they serve other functions as well, but for the sake of this discussion I’m using them as a literary device.) In this example, they serve the purpose of reminding you to ALWAYS MODIFY THE INFORMATION YOU’RE PASSING FORWARD. When you’re not at your base case, you have to send flowers to the next step of the function in order to set the stage for future invocations to reach the base case. In the above example, our flowers are sent by the `return`statement when `n > 2`:

``````return fibberfunk(n-1) + fibberfunk(n-2);
``````

Notice that each successive function calls the same function with a modified argument. In our case, we’re reducing the value of the argument we’ve passed in which brings us closer to our base case of having `n <= 2`. By modifying the argument we pass to subsequent invocations of the function, we’re “sending” information… in our case, the information we’re “sending” is that we’ve taken one step closer to the base case. This is called the “recursive case” and you might have more than one type of recursive case in your function, in ours there is only one.

It’s very, very important that you send flowers, or your function will never know when it’s reached the base case.

## 3. Recursion is not iteration

The last trick I want to share is not so goofy, but I think it should be taken seriously. I tend to remind myself that recursion isn’t the same as iteration so I don’t create `for` loops to solve recursion problems. In an iterative function, we say something like this:

``````var shmiterative = function(num) {
for (var i=0; i < num; i++) {
return num + 2;
}
};

schmiterative(5);
//3
//4
//5
//6
//7
``````

While we are passing information forward through the `for` loop, by incrementing the index, notice that `schmiterative();` is not dependent on the result of the base case to be able to calculate all the other results. Our incrementation will continue indefinitely until `i = num` but we’re able to calculate the result of every return statement without relying on the result of the base case.

Let’s hope that any of the tricks will help you get a little bit closer to solving your own recursive riddle, and if you’ve got some suggestion of how to improve or correct anything I’ve written, please let me know.

# Electromagnetic waves give us clues to the universe

For the next 6 minutes, Richard Feynman describes a “clever insect” that knows everything that happens in a pool by simply standing on the surface of a pool of water.  Wouldn’t it be clever if humans could do that, too?

# In which my excitement turns to dismay as I read poorly argued support for patents

Every once in a while, I read some argument that boggles my mind. This is one of those situations.

The name drop (IBM’s not Manny’s) left me excited me to hear what IBM’s Chief Counsel would have to say about something I’m very interested in… I figured I might learn something. In the first few sentences of Manny Schecter’s opinion piece in Wired, my brain was already was reeling. What follows are my notes as I read the article:

And they’re nothing new: Similar skirmishes have historically occurred in areas as diverse as sewing machines, winged flight, agriculture, and telegraph technology. Each marked the emergence of incredible technological advances, and each generated similar outcries about the patent system.

Paraphrase: Patents are great because they’ve always created outcries!

“We are actually witnessing fewer patent suits per patent issued today than the historical average, according to economic historian Zorina Kahn. The rate of patent litigation was twice what it is today compared to some decades in the mid-19th century.”

Paraphrase: Patents are great because they’re not rigorously enforceable! There are so many patents, we don’t even know what is patented! [noted later, in 2011 40% of patent suits are brought by non-practicing entities not companies that build devices or software]

“Economists also tell us that 75 percent of a company’s value is attributable to its intellectual property (IP) - and that IP-intensive industries contribute \\$5 trillion per year to the U.S. economy. These industries account for about 35 percent of gross domestic product and 40 million jobs, including 28 percent of the jobs in the United States.”

Paraphrase: Patents are great because the industries they protect make tons of money (that presumably wouldn’t be made if there weren’t patents). [This is a specious argument: the fashion industry makes a SHIT TON of money on similarly iteratively, innovative products].

“But six of the 10 companies globally with the highest software revenues are U.S. companies, including the top three. In other words: The success of the U.S. software industry correlates with its use of software patents to protect its innovations. If patent litigation caused by the U.S. patent system stifled innovation, U.S. software companies would not be the most successful in the world.”

Paraphrase: Patents are great because Correlation = causation! [Again, software is, by necessity, built iteratively, on the backs of others work. Patents inhibit that creative loop. It seems to me that if we buy that software should be protected, that a copyright protection makes better sense for software its written, after all.]

“And it’s not just software-focused companies. Software is increasingly the way innovation is implemented in all industries. Consider for example an automotive fuel efficiency invention that manages engine cylinder operation. A purely mechanical implementation would add too much weight, offsetting the improvements and eliminating the environmental benefits. But using software-controlled microprocessors results in enhanced efficiency, reliability, and safety … all at reduced cost.”

Paraphrase: Patents are great, because (for the next seven or fourteen years) only one car company can develop a software solution to save gas… regardless of whether they develop it on their own. We’ll protect the idea of using software to control fuel economy.~~ It’s been brought to my attention that I’m not doing a good job of explaining myself here, so I’ll let the rest of my comments stand while retracting this one.

“If an invention is novel, the idea that it should be patent-protected in hardware but not in software makes no sense.”

Paraphrase: Software patents are great because other patents are great!

“Denying patent protection for software will cause these developers to look for other ways to protect their IP investment - resulting in code that is less open, less accessible, and less interoperable.”

This is specious and circular. It relies on the argument that “ideas” are “IP” to be protected by law (something i’m willing to consider, but something which I don’t buy outright) … which is the argument in question. Copying code is hard… millions of copies of windows exist but very very very few people have access to the ‘source code’ which is why linux doesn’t look much like windows (more like osx, which copied most of its codebase from unix). It’s hard to imagine something less open, accessible & interoperable than iOS… which is owned by Apple, a huge patent portfolio.

“We’ve just begun implementing the America Invents Act: the most significant U.S. patent reform in our lifetime. Passage of this legislation required many years of hard-fought negotiation and compromise among patent system constituents. It was truly a bi-partisan, cross-industry accomplishment.”

I don’t know anything about the America Invents Act but I’m interested to learn more. Another day, perhaps… I’m going to read this rebuttal now.

In the interest of spirited debate, please let me know what you think.

# Autonomous drivers & swarms of unemployed, professional motorists

My brother hasn’t gotten a drivers license yet… and even in his mid-twenties he doesn’t feel like he should have to get one (more power to him!). So, my dad sends us this letter:

Okay - you don’t want to get a driver’s license. Here’s a possible solution from Google that will drive your car for you.

but how does it work out these solutions?

• its turn at a 4-way stop?
• its opportunity with heavy cross traffic?
• if there are lots of these cars on the road?
• if a ball rolls out into the road?
• can it tell if you are drinking when it brakes?

## My response follows:

The specifics of how it can tell the difference between a bouncing ball, a sprinting two-year-old, newspaper trash, tumbleweeds, or the neighbor’s irritating dog are complicated for sure. So, without directly answering your questions about how the machines to their magic, I would like to add that these vehicles have been driving autonomously on public roads for the last few years. Albeit, with a human at the wheel prepared to prevent troubles.

It will surely be unfortunate for a lot of gainfully employed truck- & taxi-drivers. But automated supply chains will - through greater efficiencies & 24/7 operation - drastically reduce the fuel and labor costs of the many services we use every day. Google already uses autonomous golfcarts @ their california campuses

There are some other neat applications for this sort of autonomous technology:

• Consider the case of the quadrotor helicopters or airplane drones being used to deliver medicine, food, and wireless connections to terrifically disconnected areas in emergencies or by special request. A doctor-without-borders (or a medicine man) with a tricorder-type iPhone app could call in prescriptions or vitamin deliveries.
• A swarm of quadrotors, equipped with cameras/routers/transmitters/etc… could be deployed to create a detection & communication network over a collapsed building or destroyed neighborhoods after an earthquake/typhoon/tsunami. They could be used to detect leaking gas, fires, body heat… or deploy smaller ground-based, automated sensor-equipped drones to crawl/swim/sift through the rubble to help itentify survivors.

Geez… this is gonna be a massive change!

← Newer Page 1 of 5