Tuesday 18 June 2013

Awesome 3d printed prosthetic hand!

Those who know me also know that one of my favourite gadgets is my 3d printer. It's old now and not up to the standards of todays models, but I still love and use it to build, invent, and fix things around the house.

When I got several years ago I kept trying to tell people how wonderful they were and what they could do for the world - Sometimes I got polite interest and other times I got blank indifference. People just could not think of anything they would do with one.

Today I saw one of the most awesome stories ever (on NPR).

Back in 2011 A carpenter in Johannesburg, South Africa lost several fingers on his right hand, he recovered and hooked up with a visual effects designer in the US (gotta love the internet right?) to build himself a prosthetic.

That alone is a fantastic story, but they got approached to build a hand for child born without fingers on one hand. They accept the job and built a prototype for the child out of machined metal. Then it hits them "Why not use 3d printing?"

Makerbot industries (one of the bigger players in home 3d printing) donated 2 printers to the project and our heros where able to design a hand that could be printed and assembled for about $150 in parts instead of the thousands that a normal prosthetic device would cost.

You can follow the project here or on the Robohand Facebook page.

At this point I was already overcome with awesome, but it keeps coming.

Because the design was released under creative commons, people could make their own improvements, and that what the guys at Makerbot did, they modded the design so it can be snapped together with no bolts, bringing the cost down to about $5.

I'll say it again:
$5 FOR A PROSTHETIC HAND FOR A CHILD!!!
I love my 3d printer and I love that people design things for themselves and then make the intellectual property open to benefit others.

This is not the first prosthetic designed to be made on a 3d printer - for children this type of thing is amazing because the designs can be resized every few months as the child grows without breaking the bank and the non printed parts can even be re-used. Also the printed plastic is much lighter than some of the metal alternatives, it wont last as long, but given the growth rates involved it doesn't need to.

For me a 3d printer is a way to fix blinds, kitchen fittings, dishwashers, and print up prototypes for ideas I have, but for some incredible people out there its a a tool they can use to make a massive difference in someones life.


Getting it wrong the right way!

One of my regular subscription emails turned up today open with the words:
Dear {FIRST_NAME|Colleagues and Friends},
Like most people, I've seen this happen more times than I can count (and yes I've even caused it once or twice). With the best intentions in the world mistakes happen especially when transitioning between mail providers/software.

What really caught my eye was the message I got 4 hours later:
Dear Ben,

You will have just received our XXXXXXX XXXXXXX Newsletter which has been sent out with an obvious error...

There message was short and simple: "it was human error, we're sorry." This is the right way to deal with a mistake. By taking control of it they stop (or at least reduce) complaints and demonstrate that they have already caught the mistake and corrected it.

It really highlights that there is a right way to fail, especially when people will know that you messed up... trying to hide it at that point would just make you look dishonest (and yes I've seen people try it).

Wednesday 12 June 2013

Use Gmail aliases to keep your inbox clean

If you use Gmail and you're active on Google+, Facebook, LinkedIn, Twitter, etc then you could be getting flooded with notifications you rarely read that make it hard to find the important stuff in your inbox.

You could just turn off notification but sometimes you dont want to, you just want to keep it to one side while you read the other inbox stuff. In that case you should be using gmail filters.

The only problem with filters is that you have to figure out what to filter on, sometimes it's easy and you can use the sending address or a subject, but thats not always a perfect fix.

A better solution is to use an email alias! Configure your notifications to go to the alias and then build a filter based on the to address of the email.

If you're not familiar with this Gmail alaises then you should be, its one of those must-use features when signing up for services, notifications, and subscriptions:

Google doesn't offer a traditional alias function so you dont get to just pick 5 or 6 variations of your name, but you can add as many suffixes to your regular email account as you like making as many different email addresses as you need - best of all they always make their way to your inbox without you even telling google about them.

Say for instance you gmail account is john.doe1234@gmail.com and you want an alias set up to use for your daily new subscription.

You add something like +news to the name part of your email so it becomes: john.doe1234+news@gmail.com and thats it! Anything after the plus (assuming it's still allowed characters) will get through to your account.

Because you can have multiple such alaises you could create one for each service you use:
john.doe1234+news@gmail.com
john.doe1234+twitter@gmail.com
john.doe1234+facebook@gmail.com
john.doe1234+linkedin@gmail.com
john.doe1234+googleplus@gmail.com
etc,
etc,
The best part of using an alias is that if you unsubscribe you can just change the filter to delete emails coming into that alias - ideal for those times when a website "forgets" that you don't want to see their emails any more. Also if a company does sell you email for spam you'll know, because the spam will come to that email alias.

If you want to get creative you can use it with friends and in business by creating different emails that will automatically get tagged for action:
john.doe1234+urgent@gmail.com
john.doe1234+party@gmail.com
john.doe1234+biz@gmail.com
john.doe1234+family@gmail.com
It's easy to set up a Gmail filter:

  1. Click the gear icon in the top right of the Gmail window
  2. Choose "settings" from the menu
  3. Go to the "Filters" tab
  4. Click "Create a new filter" (it's near the bottom of the page)
  5. Enter your chosen alias in the "To" field
  6. Click "Create filter with this search"
  7. Check the boxes according to your needs (I normally go with "Skip the inbox" and "Apply the label [...]")
  8. Click the "Create Filter" button
  9. Finished! 
Now your chosen emails go directly into a label (folder) and dont choke you inbox.

This is going to be old hat to many of you but it's really powerful and worth sharing with your non-tech friends to help them sort their mail for easy processing.

Real programmers are not born they are SELF-made

There must be a thousand blog posts out there saying what makes a good developer or how to train developers or how a developer should improve their skills, etc, etc... But no matter how many of them I read I always come back to one basic requirement for a good developer - They have to want to be a developer.

There is no way to over stress the importance of choice and motivation, you can put dollar signs in front of someone and they will study programming at uni and get a job, but a job is all they will ever think of it as. Real programmers think of it as a calling, it's not what they do its what they are.

I've worked with certifiable geniuses who were incredibly knowledgable and competent developers, but they were never going to be the best developers out there because it was a only a means to an end. Programming was something they did for a paycheque or to facilitate another project that actually held their passion.

A real developer (and I realise people will challenge my use of that term) is someone who writes a program to see the program run, not because they value the output.

If you have that drive, if you have the will to program for its own sake, if it's as much an interest, hobby, and life style as it is a job. Then you are a real developer - You will seek out and read the blog posts on what training you should have, on what books you should read, on what skills you should develop because you want to be trained, you want to read and you want to have the skills.

A real developer (and this applies to almost any field) is someone with the passion to drive their personal development, their career path and their life along the path towards the goal of being a developer first and foremost.

I can compress every "real programmer" test on the internet into a single question:
Q: If you won the lottery today and would never have to work again as long as you live, with enough money to do everything you ever wanted - would you be writing code in 12 months time?
If the answer is "Yes" then you are a real programmer. You program for the joy of the activity as much as the outcome.

If you answer "No" then maybe programming is just something you're doing until something better comes along.

Thursday 6 June 2013

Personal Security - Unsolicited Calls

I just read a Facebook post by a friend about a call she got from someone pretending to be her bank. My friend recognised this at once because the number they reached her on was not a number she had ever supplied to the bank.

Luckily my friend is bright enough to spot a scam quickly and hang up the instant they started asking her security questions, but I get concerned that scams like this keep working. There must be a decent percentage of people out there who dont know enough to spot this kind of scam and end up handing over important security information.

For anyone who does not know this already:
NEVER GIVE OUT INFORMATION TO AN UNSOLICITED PHONE CALL 
This is rule 1 of personal security, because if they phoned you then you have no way of knowing who they are.

Want an example?


Back in the mid nineties when the internet was still new, I was making a living building websites and setting people up on the "information super highway" as we called it back then (yes, I really am that old...), and one client challenged me to break into his ISP account... :)

The next morning I called my client on one phone and his ISP support line on another.

I told the client:
"We think someone tried access your account last night and we need to reset your password for security reasons."

I told the ISP:
"I've forgotten my password and can't login".

The I just passed questions and answers between the two phones. It took 5 minutes time, 2 phones, a pen and paper. I didn't even have to turn on my computer.

I took the client for coffee later that day and explained how it was done. I also suggested he change his password and security question.

This wasn't computer hacking it was social engineering or just plain scamming.

This thing about a phone call is that without called ID, all you know about the person calling you is that they have access to a phone, and it could be any phone anywhere in the world.

But when you call then you know they have acces to a specific phone, the phone you called. Only a bank representative is going to be able to answer the telephone banking hotline...

Whereas anyone with a phone can call you and say they are from the bank, or the tax department, or the "computer department" and then go on to ask you for your birthdate and account details.

Phishing scams like this work because out fo the huge list of email addresses or phone numbers some scammer managed to get his hands on, only a few have to be silly enough to pass on their information to make it worth their while.

The solution? Never give information out over the phone to someone you did not call or who is not calling you back on a specific issues. Never log into a site via a link in an email you were not expecting (like a message from your bank asking you to log and confirm your details).

If you get a call from a bank and they need to sort something out - even if they are claiming there has been "suspicious activity" on your account -  ask to call them back. They should always be able to give you a number to call and an issue tracking code to quote to sort it out.

Phishing is like the "i love you" email viruses that do the rounds, they rely on faults in people not in the computers.

Be a little more paranoid and lot safer.

Javascript Jedi: Getting Closure

I'm often stunned by the number people who still dont get closures... but then part of that is that closures often get confused with other Javascript goodness. Closures are used everywhere in javascript: callbacks, event handlers, private functions, you name it... they are literally all over the place. Getting a good handle on what exactly a closure is will help you understand how to use it and make a lot of the texts on javascript make a lot more sense.

So for anyone who doesn't fully get closures or wants to give a short explanation to someone else who doesn't get them, here is my take of what a closure is in it's most basic terms.

Defining a closure is actually much simpler than people think:
A closure is when one function (e.g. foo() ) is defined within the body of another function (e.g bar() ), and the inner function (foo) uses variables in the local scope of the outer function (bar).
For example:

function bar(a) {
    var msg = a;
    function foo() {
        alert(msg);
    }
    foo();
}
bar("HELLO");
bar("G'DAY");

Here we can see foo(), existing entirely inside the function bar(), and using the variable msg which exists only in the scope of the parent function.

A closure like this could be used to contain code that needs to be in a function but that you dont want shared. One common use for this exact syntax is to get around the performance hit of putting resource intensive code inside a try catch:

function bar(count){
    function foo() {
        for (var i = 0; i < count; i++) {
            /*
            Doing lots of variable assignments here!
            */
        }
    }
    try {
        foo();
    }
    catch (e) {
        // Handle your errors
    }
}
bar(1000);

In the above example a performance critical loop has been wrapped in a closure to allow the script engine to optimise it for speed (this is a bigger concern on some browser engines than others).

Far more common however is the use of closures in handling events or callbacks.

The simplest example of a callback is setTimeout() where a function name or reference is passed along with a number of milliseconds to wait before execution of that function.

function bar(a) {
    var msg = a;
    function foo() {
        alert(msg);
    }
    setTimeout(foo, 3000); // Wait 3 seconds and then run foo()
}
bar("HELLO");
bar("G'DAY");

In this case the setTimeout() calls the function foo() after waiting 3 seconds, but each call is a separate instance of bar with it's own separate instance of msg. Each closure is therefore also separate and retains the parent scope of when it was created.

The result will be two alerts "HELLO" and "G'DAY".

This could also be written using a nameless (or anonymous) function as follows:

function bar(a) {
    var msg = a;
    setTimeout(function() {
        alert(msg);
    }, 3000);
}

However... It's important to realise that a closure is NOT a snapshot of the scope. Any code put in a callback to be executed later uses the current value of a variable. For instance in the above case, if msg had been redefined before the timeout the new value would be used not simply the value of msg at the time the closure was defined.

function bar(a, b) {
    var msg = a;
    function foo() {
        alert(msg);
    }
    setTimeout(foo, 3000); 
    msg = b;
    setTimeout(foo, 3000); 
}
bar("HELLO", "G'DAY");

This example will alert "G'DAY" twice, because that is the value of msg when the both timeouts are executed.

This is important to remember when adding closures as callbacks from inside loops!

function bar(count) {
    for (var i = 0; i < count; i++) {
        setTimeout(function() {
            alert(i);
        }, 3000);
    }
}
bar(100);

All you will get here is the final value of i (100) alerted one hundred times because each callback is using the same i.

There are several ways around this but in essence all of them work by copying the variables in question out of the scope of the parent so they are not shared between callbacks.

function wrap() {
    // Convert arguments to true array
    var args = Array.prototype.slice.call(arguments, 0);
    return function() {args.shift().apply(arguments.callee.caller, args);}
}

function bar(count) {
    var msg = "Hi";
    for (var i = 0; i < count; i++) {
        setTimeout(wrap(function(x) {
            alert(msg + "-" + x + "-" + i);
        }, i), 3000);
    }
}
bar(10);

Here you pass the closure along with any variables you want to "snapshot" out of active scope to the wrap function. This then passes back another closure, however because each call to this function is a new instance of it, any arguments passed exist in their own independent scope.

You'll notice that both the msg and i variables are still from the original scope and are unaffected.

So thats my explanation of closures and my best tip for getting around their main limitation. You just need to keep in mind what scope a closure is operating in to make the best use of them.