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.
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!
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…
How do you go to work to get that coveted real-world knowledge? Why… go to school of course. Doh.
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…
Make it work. When doing clientside, that’s the only thing that should be on your mind. I see a lot of wasted time and energy devoted to making clientside code look beautiful. Why?
Clientside code is disposable. It’s the sad truth. Your code will be dead and gone in only a couple years time.
It was only two years ago this was the norm:
Fast forward to today:
Wow, what a difference a couple of years makes!
This trend will only increase in speed as even MS is switching to a rapid release cycle amid stiff competition. You’ve heard of Moore’s law? Well this is the law of the web. Things move fast, and that speed is only set to increase.
Stop worrying about maintainability. Stop worrying about maintenance. Stop worrying about that warm feeling you get when you look at all your pretty spaced and indented code.
Yeah… your code is pretty, but so what. No one cares. Does it work? Does it look good while working? Is it going to be garbage in two years — tops?
Facebook ad traffic doesn’t convert. Period.
After running an ad for a couple weeks at a modest $1k spend, we received zero conversions. That’s a goose egg.
The site being advertised doesn’t have problems selling to every other corner of the internet; yet for some reason, when it comes to FB ads, people just don’t buy.
Even if we miraculously received a sale right this second (not going to happen)… the conversion rate would be 0.08%.
This is the last time I’m tricked by Facebook’s low CPC…
In case you’re curious about the site being advertised; it receives < 1m uniques per year.