Everything that I'm working on. Heavy on the programming; heavy on the opinionated commentary.

Integrating two systems without an API client-side, with XHR and CORS


Riddle me this batman… how do you integrate data from a Private System into a third-party application without an API?

Duct tape of course!  Ok, not really duct tape… XHR/CORS.

With CORS, we can bolt integrations on to an existing codebase client-side without the need to write any new API or server code.

How does it work?

  1. Users authenticate to the Private System normally
  2. After, they log into Third-party system
  3. Third-party app makes request via XHR/CORS with credentials to the Private System, which handles the request normally
  4. This allows the third-party app to access the HTML pages directly and scrape the content to get the necessary info

There’s a gist explaining it below.

The Real World

In this particular situation, the third-party app was a Zendesk App (plugin) and the Private System was an ecommerce Admin with zero ability to communicate with the outside world.

Instead of spending weeks building and testing an API, this method allows us to get up in running in hours with almost no additional server-side code. (Just a couple new headers.)


Some general javascript sillyness.

Ever wanted to pass an object literal to a function and have those values end up as variables? No? You have a life you say?

Well here’s a way to do it. Before though, let me say that this is a pretty terrible idea and you should never do it.

function dumb(obj) {
  for (var k in obj) eval(‘var ’ + k + ’ = obj[k]’);
  console.log(hello, world);

dumb({ hello: ‘why, ‘, world: ‘hello.’ });


Can I use javascript’s undefined primitive yet?

tl;dr; No. You’re welcome.

I recently looked at some code that used javascript’s undefined primitive for checking. ::gasp:: I’ve been using typeof blah === ‘undefined’ for so long that I’ve stopped questioning the stupidity of it.

It was bad

If you don’t know, only recently (IE9?) did undefined become immutable. Previously, you could put undefined = ‘weee’; in your code and suddenly undefined stopped working everywhere.

What about now?

But today, I’ve decided to give myself a refresher and look up… what exactly is the state of undefined in js?

So… now undefined is now immutable. I can use it, right? Apparently not. Summary: it can still shit the bed in a function (confirmed in node 0.10.28).

FML. Stuck with typeof blah === ‘undefined’ then? Not exactly.

A kinda hacky workaround

Enter void 0.

Another thing that I’ve always aVOIDed is void (wordplay is the lowest form of humor). I apparently absorbed that through the ethos from Crockford, as it was one of his bad parts of JS.

But turns out, void 0 *always* returns undefined (the real undefined), and can be used to strict compare; like var b; b === void 0; // true.

Yay! I’ll just use void 0! Well… almost. GOTO FML.

You’ll get an exception if you try to compare against a variable not in the local scope. That is… blah === void 0 = exception. var blah; blah === void 0 = true.

in operator

However! We have the in operator for non-local vars — which I (terribly) never used, for no reason in particular.


It’s better not to play. Stuff should be defined unless you know better.

If you absolutely need to check though:

  • Local: localBlah === void 0
  • Global: ‘whatever’ in window (global) — be sure to see these caveats here especially with regard to deleted/undefined properties.

Bye bye typeof/undefined.

Quick http proxy/forwarding script for getting around CORS while developing locally

Sometimes when building clientside stuff, CORS can be a pain in the ass.

Images in a canvas… remote APIs… remote resources… any of these things can trigger a browser security error and you stopping work. 

You could always set up a fancy dev environment and combine multiple endpoints behind a proper single proxy server so that everything shows up all nice and pretty behind the same origin.  

Or… you could hit it with a hammer.  

I prefer the latter.

That’s why I created a simple script that will take anything you send to it, and forward it on to another host and return the result.  It’s not really a proxy… it’s mainly a garbage script that helps you get back to work.


Use it like so: node proxy.js [optional port, defaults to 9100]

Then anything you fire at it in this format will get forwarded on: http://localhost:9100/http://www.google.com

I’ve only used it with GET so far, but in theory it should also work with all those crazy verbs you kids are using.  Like POST… or PUT… or HEAD… Heh… head.  Silly kids…

Everything after the first slash is sent as-is, so (in theory) the query string should work properly too.

Oh, and it will follow redirects and also handles 304s.

Remember: This is *NOT* for anything other than development. If you use this in anything resembling production, you deserve a beating.

So you want to screenshot or take a thumbnail of a FabricJS canvas…

Sounds simple, right?  Wrong.

I’ve been digging into fabricjs for a little while now for a pretty large project I’m working on.  Conclusion?  It’s a bit of a mess… to say the least…

First, let’s get the solution to your problem out of the way, and then I’ll explain why I’m beginning to regret going with Fabric.

I ripped this right out of my code and replaced the vars on the fly, so YMMV with running it.  

You’ll need a couple different fabric canvases and then a canvas for your generated thumbnail.  Here it is: real-time thumbnails of a FabricJS canvas without selection controls and other crap:


Now… you’re probably asking yourself.  Why can’t I just grab the contents from fabricMain and be done with it?

Answer: Because there is no way to grab it without the controls being visible. (Please correct me if I’m wrong.  *Please!*)

Can you hide the controls temporarily?  No.  I couldn’t even find a way to deactivate/reactivate a selection — which would be a terrible solution from a UX perspective.

That’s why you need to use the intermediary canvas.  So that we can grab a control-less image without fucking up our user’s selection.

So what’s with the activeGroup stuff in that code?  I have no idea.  For some reason, if there is an activeGroup, the cloned objects will not show up in the fabricThumb canvas….?  Bug? Feature?

Try it… select 2 objects and poof, they’re gone from the generated thumbnail.  Select no objects and they’re all back.  Select one, they’re still both there.  I got nothing…

So that is why we need to wade into the evil waters that is the activeGroup and do all that other BS for something that should be relatively straightforward and common. Phew!

Screw Your Degree: My rant against the higher-learning industry


There was an argument by someone against certifications (link lost :[ ) It basically went like this…

Certifications are BS.  Anyone that gets a cert is invested in seeing that cert become a standard because they have it, and the better that cert looks, the better they look.  

Case in point: HIPAA certifications.  Spoiler alert: HIPAA requires no certification.  Yet hospitals continue to advertise the pricey certifications they’ve received.  

I feel this problem is extended to include higher-learning in general.  The way we’ve structured things — it’s one big collegiate ponzi scheme.

If you get a degree… you hire more people that have education like yours and you put more value in degrees in general.  (todo: cite)

In other words, you’ve drank the koolaid.  

And as someone w/o a degree, I inherently care less about them, and have been bothered enough to rant on the topic… see how human behavior works?

As a degree recipient, you’ve invested in that paper with your mind, body and wallet — for better or worse.  You’re probably proud of the accomplishment.  Good for you…  attaboy… and some other such words.

Something like 70% of all job experience comes from working the job itself. (todo: cite)  You’re not an expert until you have 10k hrs of work experience (~10y). (todo: cite)

My takeaway is…

  1. Go to school if your parents are wealthy and you want a philosophy or photography degree — or any degree that causes people to snicker at how less-than-useful it’ll be at putting a roof over your head…

  2. Go to work if you’re stuck in the real world, with the rest of us

How do you go to work to get that coveted real-world knowledge?  Why… go to school of course.  Doh.

Why I returned Google Glass: A narrative

As a developer, I’ve had an idea for Glass for some time. I was disappointed to not get it in the first round of purchases and instead picked up an Oculus Rift to do some augmented reality dev.

However, a couple months ago I received an email with an invitation to purchase Google Glass! Now, I should say I’m still a huge believer in the tech, but since Glass is in the news again, I decided to type up this first-person account of why I returned Google Glass.


An invitation! Oh happy days! I’ve had an idea for Glass that I’ve been waiting to try. $1,650 (tax)? No problem, it’s that awesomeness!

I’ll have it shipped to me, please. I don’t need that circle jerk that is a visit the Google campus for a “fitting”… thanks though.

And now the beautiful box has arrived! I’m a kid on Christmas. Oooo… so shiny and nice and pretty and shiny!

Ok… this is kinda weird, it is just a tiny little screen in the upper right corner. And wait, if I flip it around, I can see the screen from the outside world. Hmm… Oh well, I just won’t look at pr0n on my awesome Glass.

Swipe, swipe, tap, swipe. “Define glass”. Great.

And now to get some directions to places I’m not going… that’s kinda cool.

Why is my temple getting warm? Oh, because this thing is getting hot after a few minutes of use. That’s not good.

Annndddd…. the battery is dead. Lame.

Oh well, you probably won’t be using it non-stop like that in the real world, and it didn’t even have a full charge to start. I’ll just charge it and wait for another go.

Time to do dishes, I’ll entertain myself with Glass now that it’s charged. This seems like the perfect use-case.

Both my hands are wet… “ok glass”. Nothing. “ok glass”. Nothing. Oh, I need to enable “head-tilt” to turn it on hands-free. Done. Ok, that kinda works… wait… I still need to swipe and tap? What the fuck? What good is this thing other than lording it over others? I’m returning this shit…

Loading... No More Posts Load More Posts