How to get S3 to send CORS headers using Origin

November 19, 2015

I’ve been trying to make Vary Origin work with Amazon Web Services S3. Here is how.

You need to Add CORS Configuration. Paste in the following:

How to test

Open the terminal or command line and using curl:

I sent the origin as

You should get this response:

Note the above where I am able to get the Access-Control-Allow-Origin to return as well.

Copy to clipboard without Flash

September 30, 2015

Typically you will use a Flash hack for this but thanks to better browser support, you won’t have to do this anymore:

A modern approach to copy text to clipboard. No Flash. No dependencies. Just 2kb

Source: clipboard.js — Copy to clipboard without Flash

Start by using npm install:

And the implementation could be as simple as this:

Where .btn refers to the classname of the button where the click will trigger the pasting things of items from the clipboard.

Learn to code

September 1, 2015

Eric Elliott on why you should learn to code or teach the homeless how to code.

Interesting points:

the demand for programmers is rising twice as fast as the average job growth rate: About 20% year over year. The US Bureau of Labor Statistics estimates that by 2020 there will be more than 1 million unfilled computer programming jobs.

Computer programmers earn about twice as much as those who don’t code, on average. In other words, programming provides long-term job stability, strong growth prospects, very strong wages, and the best part is, you can learn to code well enough to get a job in as little as 5 months.

Node.js 4.0 converges iojs

August 14, 2015

The first fully converged io.js/node.js release coming soon.

Last week was a typical San Francisco summer, sunny with occasionally hostile winds. This was the setting for 40 node.js contributors to gather for the first ever Collaborator Summit, organized by the new Node.js Foundation.

A year ago we didn’t have 40 contributors to gather but today this represents only a fraction of the total contributor base (359 GitHub org members as of 8/12). This is due in large part to Joyent’s migration of node.js to a foundation and the merger of io.js into that foundation. As a unified project node.js has seen more progress than ever and will soon see Node.js v4.0 — the first unified release of the io.js and node.js codebases.

Book review: JavaScript Allongé “Six” Edition

July 25, 2015

Reg “raganwald” Braithwaite updated his book, JavaScript Allongé, to include ES6 in it.


In the new “Six” Edition, brand new chapters are added specific to ES6 (or ECMAScript 2015 if you prefer). If you’re looking for a book to start learning JavaScript, this is an excellent book too begin with.

If you had the previous JavaScript Allongé book, you will definitely be delighted that all previous examples have been rewritten to use “const”, “let” and other ES6 goodness. I consider this an almost full rewrite.

The focus is largely on functions and ES6’s new function syntax made things so much more readable.

There is a section on composing class behaviors which introduces ES6 classes and mixin patterns that I learnt a lot from.

Buy his book here. You can also begin with a free sample here.

Why should you not use semicolons

July 20, 2015

I went through this discussions a lot, whether you should use semicolons or not. After a while it felt like a lot of unnecessary discussions was coming through. Most people are arguing are arguing on familiarity and that’s hard to sell.

This video provides a good explanation why you should probably not have semicolons:

I’ve been coding JavaScript in my day job of the past 2 years and I just switch my company to not use semicolons. There was initial confusion but within 2 weeks, everyone pretty much goes on just fine.

Overview of Babel

July 16, 2015

Cool explanation of how Babel works. A must-watch if Babel’s already part of your workflow and you want to learn more:

Sebastian McKenzie speaks on improving Your Workflow With Code Transformation.

Testing default and rest parameters

June 7, 2015

Take a look at this example. I set default parameters for ‘a’ and ‘b’ in the function.

If the parameter is not set with a default value, it behaves very much like how it would in ECMAScript 5.1 — undefined. See the parameter c.

The final parameter is a rest parameter ...d, i.e. 3 periods followed by the variable name. This is supposed to take over the older arguments variable. It will always be defaulted to an empty array.

Happy 2nd birthday React.js

May 31, 2015

Happy 2nd birthday React.js. Kind of:

I didn’t realized React.js has been 2 years of fun. At my workplace we shifted to React.js and then out. It’s unfortunate but till the next time we meet!

%d bloggers like this: