Skip to content

Instantly share code, notes, and snippets.

@johnjbarton
johnjbarton / gist:30c3e72d51d9d64e36d1
Created May 5, 2014
Proxy .__proto__ vs getPrototypeOf
View gist:30c3e72d51d9d64e36d1
<script src="../third_party/harmony-reflect/reflect.js"></script>
<script name="testObjectCreate">
(function() {
var aPrototype = {foo: 'foo'};
function createProxy(obj) {
return Proxy(obj, {
get: function(target, name, receiver) {
console.log(' (Proxy handler \'get\' called for name = ' + name + ')');
if (name === '__proto__')
@johnjbarton
johnjbarton / gist:f8a837104f0292fa088c
Created May 5, 2014
Proxy fails in Object.create()
View gist:f8a837104f0292fa088c
<script src="../third_party/harmony-reflect/reflect.js"></script>
<script name="testObjectCreate">
(function() {
var aPrototype = {foo: 'foo'};
var handler = {
get: function(target, name, receiver) {
console.log(' (Proxy handler \'get\' called for name = ' + name + ')');
return target[name];
}
@johnjbarton
johnjbarton / gist:6a4d0871f2cc0ca9cc3d
Created May 5, 2014
Proxy fails in Object.create()
View gist:6a4d0871f2cc0ca9cc3d
<script src="../third_party/harmony-reflect/reflect.js"></script>
<script name="testObjectCreate">
(function() {
var aPrototype = {foo: 'foo'};
var handler = {
get: function(target, name, receiver) {
console.log(' (Proxy handler \'get\' called for name = ' + name + ')');
return target[name];
}
@johnjbarton
johnjbarton / gist:8464796
Created Jan 16, 2014
jitus deploy --debug
View gist:8464796
ESC[32minfoESC[39m: Welcome to ESC[90mNodejitsuESC[39m ESC[35mjohnjbartonESC[39m
ESC[32minfoESC[39m: jitsu v0.13.9, node v0.10.4
ESC[32minfoESC[39m: It worked if it ends with ESC[90mNodejitsuESC[39mESC[1mESC[32m okESC[39mESC[22m
ESC[32minfoESC[39m: Executing command ESC[35mdeployESC[39m
ESC[32minfoESC[39m: Analyzing application dependencies in ESC[35mbuild/printSemver.jsESC[39m
ESC[34mdebugESC[39m: { method: ESC[32m'GET'ESC[39m,
ESC[34mdebugESC[39m: uri: ESC[32m'https://api.nodejitsu.com/apps/johnjbarton/traceur'ESC[39m,
ESC[34mdebugESC[39m: headers:
ESC[34mdebugESC[39m: { Authorization: ESC[32m'*********************************************************************'ESC[39m,
ESC[34mdebugESC[39m: ESC[32m'Content-Type'ESC[39m: ESC[32m'application/json'ESC[39m },
@johnjbarton
johnjbarton / gist:8464209
Created Jan 16, 2014
jitsu deploy gives 500 error, here is the package.json
View gist:8464209
{
"name": "traceur",
"version": "0.0.10-1",
"description": "Experimental ES6 to ES5 compiler",
"keywords": [
"javascript",
"ecmascript",
"language",
"es5",
"es6",
@johnjbarton
johnjbarton / backbacktick.js
Created Aug 7, 2012
quasi-literal vs function calls
View backbacktick.js
// Comparing some of the use-cases for 'quasi-literals' aka string templates to normal functions and strings
// http://wiki.ecmascript.org/doku.php?id=harmony:quasis#syntax
x`foo${bar}baz`
// vs
x('foo',bar,'baz');
// http://wiki.ecmascript.org/doku.php?id=harmony:quasis#secure_content_generation
safehtml`<a href="${url}?q=${query}" onclick=alert(${message}) style="color: ${color}">${message}</a>`
@johnjbarton
johnjbarton / esSubclass.js
Created Nov 14, 2011
Refactoring of Irakli Gonzala's extend() from git://gist.github.com/1361599.git
View esSubclass.js
Object.defineProperty(Object, 'mergeDescriptors', {
value: function() {
// Shallow copy of the argument property descriptors, right most wins
//
var properties = {}
Array.prototype.slice.call(arguments).forEach(function(source) {
Object.getOwnPropertyNames(source).forEach(function(name) {
properties[name] = Object.getOwnPropertyDescriptor(source, name)
})
})
@johnjbarton
johnjbarton / minimalist-classes.js
Created Nov 13, 2011 — forked from Gozala/minimalist-classes.js
Gonzala extend with comments
View minimalist-classes.js
// Here is a proposal for minimalist JavaScript classes(?), that does not
// introduces any additional syntax to the language, instead it standardizes
// approach already used by majority of JS frameworks today.
// !!! What is a PROBLEM!!!
function Dog(name) {
// Classes are for creating instances, calling them without `new` changes
// behavior, which in majority cases you need to handle, so you end up with
// additional boilerplate.