Hackernoon logoA Magician Never Reveals his Secret — Unless it’s for Hacker Noon by@Webb

A Magician Never Reveals his Secret — Unless it’s for Hacker Noon

image
Thomas Webb Hacker Noon profile picture

@WebbThomas Webb

It’s a classic saying; a magician will never reveal his secret. Why? Well, the secret is always far less impressive than the trick. Magicians use a fundamental assumption when performing magic, that people can’t think about more than one thing at once. Especially if you’re showing them something with an object they see every day. E.G. a pack of cards or in today’s world, and iPhone. People tend to switch off and go into autopilot mode in the same way they do when they’re driving a car.

Magicians and hackers are more similar than you think.
Hackers understand technology, electronics and code more than 99% of people and can use this knowledge to manipulate and control what users see, think, and believe in the digital space. 
Magicians do the same thing, in the physical space, with sleight of hand and mentalism.

As someone who has done both, the similarities are shocking, but there is one monumental difference. Magicians perform magic to laypeople for applause. Hackers hack for fun, for exploration of the digital realm and what can be invented for science/art/tech sake.

I will for the first and hopefully not the last time here, reveal one of my secrets. Why?

I love technology, innovation and creativity, magic is just a trick, it’s embarrassing to be

Watch this, it’s my America’s Got Talent Audition:

Tom London America’s Got Talent Audition

Now you’ve watched that, you either have a lot of questions or want to ask me if your theory as to how it all worked was correct.
That’s what Twitter is for. Hit me up.

This whole thing was a mission, literally, but also a dream.

Controlling thousands of mobile phone screens in real-time

My initial concept: to be able to control the screen on mobile phones over the internet. More precisely:

Give the impression I clicked my fingers and hacked 2000 phones, in less than 100ms.

What can’t I do

I have to be able to control 2000+ devices, in real-time, and no one can know it’s happening. 
Easy enough if they’re all on the same wi-fi network right?
‘There’s no wi-fi in the auditorium’ said the fat inspector.

First thing I did was eliminate everything I can’t do because of the audition/stage performance/television show constraints:
- No wi-fi.
- No time for the audience to download an app.
- Can’t physically touch any of the users’ devices.
- Can’t actually tell them anything before I walk on stage.
- Can’t actually do real magic (shock).

Basically I can’t do it.

Until this.
PubNub.

PubNub is a real-time data messaging platform, well, they were a year ago. Now they do cloud functions, server blocks and time-saving magic on their data stream, I mean, they power everything I do these days.

I got in touch with Stephen Blum, CTO of PubNub.

Enter my first SF tech company email thread experience.

Stephen replies with this.
Minutes later.
I then had to convince him I was real?

After a couple skype sessions, Stephen hooked me up with Jason and Jasdeep, two of his guys who worked with me and my father (sick programmer) on my web app which did the following.

PubNub Magic

PubNub works like a giant whatsApp group. You can create a group chat and different services, programs, servers can all subscribe to the chat and understand what’s going on by using a universal language like JSON for storing your data.

What’s cool about PubNub is that they have a SDK or API for pretty much everything. Kettle, Sex Toy, Nintendo Switch. There’s probably an SDK for it. (There is literally no SDK for any of those things but yeah, you get it)

Controlling the devices with PubNub

I created a landing web page that ran a javascript script hooking the page up to pubNub and subscribed it to my channel ‘magic’.

I then took out another 3 mobile phones I had laying around and watched them all connect. I then typed out a message ‘Go’ into the pubnub console and watched it fire across the internet to the devices. Once the devices got the message, the javascript triggered a onDelay event which changed the background color of the HTML body.

Sick. Hacking the mainframe.

Pubnub fires this tiny, several kb message across the internet in less than 100ms and all I had to do was implement their API.

I tested this at an event in Barcelona for the launch of Now You See Me 2. Actually it was the pre-screening and my client was the VP of Lionsgate. They wanted me to create some magic that recreated the movie so I got to watch it 6 months early and build this very trick. Click a button, make everyone's devices flash the brand colours. I had about 600 people using it at the same time, looked insane. Bingo, on to something.

Synchronising devices

if you remember from the video when I raised my hands the devices quite beautifully started blinking almost exactly at the same time.

This was harder to do, for many reasons. Firstly, the devices are in an auditorium which means concrete, metal, radio signals from other devices and dreaded microphone radio waves. All this noise is going to slow down the 3G/4G/LTE/Edge connections on the devices.

What was crazy was that I only realised this the day before the live audition.

At this point, Stephen got two of his team involved, Jasdeep and Jason. They flew out to Studio City in LA and we sat down together over an Unami burger and stressed out for 24 hours about how we could make it work.

We came to the conclusion the best way was to work out the device time and the compare this to the server time. This would allow us to create a universal time for all the devices, by working out the local device time difference and adding/subtracting it from our server time.

The server would then send out a message through PubNub, the message contained some information in a JSON object which stated the time at which the devices should start flashing in the future, 10 seconds into the future. This meant that once I started the routine, there was 10 seconds for the message to get sent to every device, and no matter how long it takes for them to get the message all the devices would theoretically start at 16:47 (for example).

It worked better than I expected, I had devices in 5 countries during testing starting the sequence and precisely the same moment.

I just realised, I created a real-time mobile phone screen system. PubNubs messaging system allows me to have theoretically… millions of devices.

Picking 5 devices out at random

After all the devices flash, I mention to Simon Cowell that I selected 5 devices at random. This was really, really, really cool.

When the device subscribes to the stream, it issues a UDID and publishes that to PubNub. This gives me a list of every single device. My server goes through the list, picks 5 at random and pushes them down the PubNub stream. If the local device UDID matches any of those 5 on the stream, the device changes state to ‘chosen’. We’re talking a few lines of code here to do something I would consider incredibly complicated without PubNub.

How I did the number trick.

Well, that’s a story for another day. No, I didn’t use ‘TOXIC’.

  • Toxic is where you type a number into the iPhone calculator and enter in a random number (call it rN) press, Plus, 0, Times, Left Bracket, Cancel. The result is any number of numbers multiplied together will = rN. I didn’t do that.

I get asked how I did this on a daily basis, it was just some clever web app. I’m also shocked that when I perform this at keynote addresses, using it to open apps with pre-filled content or compose emails some people believe I actually have hacked them. You can get away with so much today if you understand the universal level of knowledge most people have for the technology they use.

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.