Skip to content

Instantly share code, notes, and snippets.

View espadrine's full-sized avatar

Thaddée Tyl espadrine

View GitHub Profile
@espadrine
espadrine / template.svg
Created January 13, 2014 08:48
Using an OpenSans subset font. Contains 'a'..'z' and a space.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@espadrine
espadrine / build-passed.svg
Created January 2, 2014 12:49
Github badges. All svg images here are licensed CC0.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@espadrine
espadrine / tokenizer.js
Last active February 23, 2016 01:51
Raw tokenizer taken from Esprima.
/*
Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
Copyright (C) 2013 Mathias Bynens <mathias@qiwi.be>
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
// Automatic Generation of Random Names.
var vowels = ['a', 'e', 'i', 'o', 'u', 'y'];
// Most common letters, digraphs, trigraphs and doubles.
var graphs = ["e","t","a","o","i","n","s","r","th","he","an","in","er","on","re","ed","nd","ha","at","en","es","of","nt","ea","ti","to","io","le","is","ou","ar","as","de","rt","ve","the","and","tha","ent","ion","tio","for","nde","has","nce","tis","oft","men","ss","ee","tt","ll","mm","oo"];
var startWithVowel = graphs.filter(function(e) { if (vowels.indexOf(e[0]) >= 0) return e; });
var startWithConsonant = graphs.filter(function(e) { if (vowels.indexOf(e[0]) < 0) return e; });
function pick(l) {
@espadrine
espadrine / toml-argument.md
Last active December 14, 2015 04:29
Things I like / don't like about TOML

4 Things I Find Great About TOML

  • Arrays allow trailing commas!
  • Comments! (From a JSON perspective, that's huge!)
  • Dates are UTC!
  • Simple syntax, no semicolon / commas, no need to check for matching braces!

4 Things I Don't Like About TOML

@espadrine
espadrine / objectunion.js
Created February 2, 2013 23:54 — forked from puffnfresh/objectunion.js
Cannot resist. Must add memoization.
// Boilerplate
function objectUnion(definer) {
var defined = 0, length = 0, isDefined = false, definitions, key;
definitions = definer(function() {
var names = arguments, fold;
if(isDefined) {
throw new TypeError('This objectUnion has already been defined');
}
function wrapped(args) {
@espadrine
espadrine / parse-tokenize.js
Last active December 11, 2015 19:19
Speed testing: Esprima parse vs. Reflect parse vs. Esprima tokenize. Put this in Firefox' scratchpad.
var jquery = "/*!\n * jQuery JavaScript Library v1.9.0\n * http://jquery.com/\n *\n * Includes Sizzle.js\n * http://sizzlejs.com/\n *\n * Copyright 2005, 2012 jQuery Foundation, Inc. and other contributors\n * Released under the MIT license\n * http://jquery.org/license\n *\n * Date: 2013-1-14\n */\n(function( window, undefined ) {\n\"use strict\";\nvar\n\t// A central reference to the root jQuery(document)\n\trootjQuery,\n\n\t// The deferred used on DOM ready\n\treadyList,\n\n\t// Use the correct document accordingly with window argument (sandbox)\n\tdocument = window.document,\n\tlocation = window.location,\n\n\t// Map over jQuery in case of overwrite\n\t_jQuery = window.jQuery,\n\n\t// Map over the $ in case of overwrite\n\t_$ = window.$,\n\n\t// [[Class]] -> type pairs\n\tclass2type = {},\n\n\t// List of deleted data cache ids, so we can reuse them\n\tcore_deletedIds = [],\n\n\tcore_version = \"1.9.0\",\n\n\t// Save a reference to some core methods\n\tcore_concat = core_deletedIds.concat,\n\tcore_push = c
@espadrine
espadrine / assert.js
Created November 19, 2012 14:57
The only assert implementation that makes sense
function assert(condition) {
if (!condition) { debugger; }
}
@espadrine
espadrine / reflect-vs-esprima.js
Created August 5, 2012 07:50
Reflect.parse vs. Esprima
// In order to get Reflect.parse, we need to run this in a chrome environment.
Components.utils.import("resource://gre/modules/reflect.jsm");
function Esprima(exports) {
'use strict';
var Token,
TokenName,
Syntax,
@espadrine
espadrine / client.js
Created June 26, 2012 18:25
Isaac's Module Idea
let {sum, pi} = import './math.js';
alert('2n = ' + sum(pi, pi));