Victor Powell

Apr 14

Fibonacci in Rust

// (the slow, recursive way)

fn fib(x :int) -> int { match x { 0 => 0 , 1 => 1 , _ => fib(x-1) + fib(x-2) } } fn main() { let mut n = 0; while n < 40 { io::println(fmt!("fib %?: %?", n, fib(n))); n += 1; } }

Jan 02

what do I want?

A while ago I was asked the question “what do you want?” it took me back. It wasn’t something I really thought of much. So I took the time to write a few things down and a few days ago I came across that textfil. here it is bellow:

I want to be in control of what I decide to work on.

I want to be take pride in the quality of the things I make.

I want to make things people not only use, but fall in love with.

I want there to be a direct correlation between the quality of work my and how much money I make.

glad to see my opinions haven’t changed :)

Dec 12

Thoughts on the movie ‘12 Monkeys’

I know I’m a little late to the party but I just watched the move 12 Monkeys and was so blown away, I was inspired enough to write down some of my thoughts. There was one scene in particular I couldn’t wrap my head around; the final scene, when the woman scientist (astrophysicist) is seen on the plane next to the bio terrorist, she mentions she’s “in insurance.”

image

My first thought was that it was simply a coincidence. That she unknowingly sat next to the bio terrorist in the past. But she wasn’t as young as she should have been as suggested in the age difference between young and old Cole. This small scene changes completely my original interpretation of the film because up until that point, it seemed Cole was very much unable to effect his past and that he was always destined to witness his own death. 

After some Googling, it turns out I wasn’t the only one perplexed by this scene. One theory was that the past in the movie was in fact, changeable and the scientist on the plane was there to “ensure” the bio terrorist went through with his plain in light of Coles actions. I remained in disbelieve of this opinion until the commenter posted a link to the original script which describes Jose’s reaction to hearing the details of the bio terrorist and what plane he’s flying out of. The script reads specifically, “JOSE, having heard this, steps back into the crowd as RAILLY grabs COLE and pulls him toward the Security Check Points.” This means Jose was after that information from for the scientists so they could make sure he made it onto the plane! The scientists had no intent on changing the past and that the past, was actually changeable.

Another scene in the movie that supports this theory is that in an early flashback to Cole’s memory of the incident at the airport, Cole sees Jeffrey as the man with the ponytail and suitcase running for the gate, implying that Jeffrey may have been the original terrorist until the past was altered.

image

Dec 02

The appreciability of code as art

Code is art. If you google “what is art?” you get the following response

The expression or application of human creative skill and imagination

By this definition, code should rightfully be considered art but few self described artists give it this rightful designation. I thing this has to do with what I call codes lake of  ”appreciability.” Take music as an example. It’s fairly easy to argue that any one of Beethoven’s works can be considered art. This is because it’s easy for almost everyone (at some level) to appreciate music. You need no formal education to enjoy it. (Although, I’m sure having a deeper understanding of music helps you to better appreciate the level of detail and mastery expressed in his work.) So with music, everyones born with the ability to appreciate it, only a few go on to master it. Programming is different, in that to appreciate it, you have to have mastered it (or at least be proficient at it.)

Nov 18

I’m dyslexic and I program

I’m dyslexic. And no, that doesn’t mean I read backwards. It also doesn’t mean I’m stupid. From wikipedia:

Dyslexia is a brain-based type of learning disability that specifically impairs a person’s ability to read. These individuals typically read at levels significantly lower than expected despite having normal intelligence.” —

National Institute of Neurological Disorders and Stroke

But in middle school, my teachers all just about gave up on me ever being able to read, write or spell at a proficient level and so did I. They gave me a laptop that came with software that would translate text in speech and the audio versions of my reading assignments and sent me on my way. And so, for the longest time, I believed I would never need to read or write. What was the point? Technology could already do this task for me. So I almost never read or wrote anything. Nor did I want to. It was hard and frustrating and everyone could do it better then me.

With the computer I was given, I learned to type. And better and more quickly then any of my peers. Typing, it turns out, was a great way to learn how to spell. I could memorize the motion of my fingers instead of trying to remember the order of letters.

Then, another interesting thing began to happen. I learned to program. In art class, we used Adobe Flash to create animations. I found myself wanting to create interactions and more complicated motions, so I learned ActionScript. As long as I could find tutorials with several examples, and relatively little text between them, I could get my animations to do what I wanted. And so by accident, I found an entire would inside of ActionScript for doing all kinds of neat things. I could even make video games!

Because of all the time I was spending trying to follow tutorials, my ability to read slowly improved. After I got to college and decided to major in Computer Engineer, a really great thing happened. Someone suggested a book for me to read. The book was called Outliers. It was the fastest I’ve ever read a book and probably the first book I ever read that I truly  enjoyed reading. So I read Blink and The Tipping Point just as quickly after that. Somehow reading wasn’t a struggle while reading those books. It was like riding a current down stream, instead of feeling like a fight upstream. I reached some sort of critical mass, where the enjoyment factor outweighed the choir.

There’s a lot of research in the area in neuroplasticity that suggests increasing remedial reading can offset the effects of dyslexia. Let me say that another way, reading more makes you less of a dyslexic. The prevailing wisdom on dyslexia up until recently has basically been if you got it your stuck with it. Which makes sense, since the one thing dyslexics don’t want to do its read more so they never improve.

It seems more and more that reading and writing is like the internet itself and being better at both is analoges to improving your download and upload bandwidth. I feel very strongly that reading and writing on the web isn’t just a fad. It’s going to be the primary communication protocol for us humans on the internet for a very long time to come. It should be our priority, as a society, to teach the fundamentals of communication above all else in school. As long as kids are able to communicate, they’ll gravitate toward their interests and fields of choice on their own teaching themselves along the way.

Jul 16

Zookeeper with node.JS on OS X - Part 2: Setting up the Node.JS Client

At first I thought node-zookeeper was the best module out there for working with zk and node but the API is gross. I was glad to find out I wasn’t alone. Mark Cavage from Joyent was kind enough to write a wrapper around it that makes it feel more like the native node file system api. You can find it here: https://github.com/mcavage/node-zkplus or just install it via npm

npm install zkplus

then just write your client code. Here’s the usage example taken from the github project:

var assert = require('assert')
    , zkplus = require('zkplus')

var client = zkplus.createClient({
    servers: [{
        host: 'localhost'
        , port: 2181
    }]
});

client.on('connect', function () {
    client.mkdirp('/foo/bar', function (err) {
        assert.ifError(err);
        client.rmr('/foo', function (err) {
            assert.ifError(err);
            client.close();
        });
    });
});

Zookeeper with node.JS on OS X - Part 1: Installing Zookeeper

To get started, you’ll need to install zookeeper. I’ll assume you’re using OS X. In which case, you can install zookeeper via home brew.

brew install zookeeper

if that breaks because of a permissions issue mentioning the directory 

/usr/local/var/run/zookeeper

just go ahead and create that folder using sudo:

sudo mkdir /usr/local/var/run/zookeeper

after that, make sure to change the owner to the current user

sudo chown victor:victor /usr/local/var/run/zookeeper

Now just try running brew install zookeeper again

zookeeper should now be installed in 

/usr/local/Cellar/zookeeper/

You’ll also want to setup the zookeeper configuration file in

/usr/local/etc/zookeeper/zoo.cfg

I was able to just copy the example cfg to zoo.cfg from within that directory. tl:dr, your cfg file should look like this: https://gist.github.com/3126340

To clean up all this mess, I also added a small shell script that I put in /usr/local/bin that looks like this https://gist.github.com/3126356. make sure to also set the file mode to executable using

chmod +x zookeeper

so that zookeeper will find our cfg file and use the proper directory to store its data. this will also let us do

zookeeper start

to start the server or

zookeeper stop

to stop it. yay!!

Jul 13

Running scala as a scripting language

If you ever want to try out scala, or even if you just want to write a quick scripts that utilizes some native java code, the scala interpreter might be a great choice. After you install scala, instead of waiting for your code to compile, just run your code as a script.

#!/bin/sh
exec scala "$0" "$@"
!#

import java.util.ArrayList

object MyScript {
    def main(args: Array[String]) {
        val a:ArrayList[String] = new ArrayList[String]
        // add the arguments
        for(arg <- args) a.add(arg)
        // add some extra args
        a.add("first extra argument")
        a.add("second extra argument")
        for( e <- a.toArray() ) println("arg: "+e)
    }
}
MyScript.main(args)