Skip to content

Instantly share code, notes, and snippets.

View colingourlay's full-sized avatar

Colin Gourlay colingourlay

View GitHub Profile
@colingourlay
colingourlay / index.js
Created June 28, 2016 21:02
Reduce list of 11 multiple (4) choice question answers to 4 character code, and re-inflate it again.
const CHARSET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$_';
const MASK = parseInt('111100', 2);
let guesses = [...Array(11)].map((item, index) => {
return Math.floor(Math.random() * 4);
// return index % 4;
});
console.log(guesses);
@colingourlay
colingourlay / esnextbin.md
Last active March 3, 2016 22:36
esnextbin sketch
@colingourlay
colingourlay / web-worker-vdom-challenges.md
Created January 23, 2016 09:17 — forked from lawnsea/web-worker-vdom-challenges.md
A discussion of the challenges I anticipate we will face creating a widely useful system based on a virtual DOM running in a web worker

I have been watching the current discussions about running a virtual DOM in a web worker with a great deal of interest. In 2011, I built a research project, [Treehouse][] ([USENIX Talk][] ([DOMTRIS][] demo at 20:25), [paper][]), which ran a hacked-up version of jsdom in a worker. My goal was fine-grained containment of untrusted scripts, while still providing access to browser APIs that existing code expected.

Treehouse achieved a small amount of influence in academic circles, but it had problems and was ultimately unsuccessful. Virtual DOMs were not a widespread or well-understood idea at the time, so the advantages of running one in a worker

@colingourlay
colingourlay / index.js
Last active January 17, 2016 05:01
Using crel + hyperstyles (browser only)
var hyperstyles = require('hyperstyles');
var styles = { /* Mock CSS Module */
'root': 'Car__root___fg434',
'front-door': 'Car__front-door___b85f9',
'back-door': 'Car__back-door___p9h7j'
};
var crel = hyperstyles(require('crel'), styles);
function render() {
return crel('div.root',
@colingourlay
colingourlay / index.js
Created January 17, 2016 03:38
Using virtual-hypercript + hyperstyles + hyperx
var vdom = require('virtual-dom');
var hyperx = require('hyperx');
var hyperstyles = require('hyperstyles');
var styles = { /* Mock CSS Module */
'root': 'Car__root___fg434',
'front-door': 'Car__front-door___b85f9',
'back-door': 'Car__back-door___p9h7j'
};
var hx = hyperx(hyperstyles(vdom.h, styles));
@colingourlay
colingourlay / location.txt
Created December 8, 2015 13:39
Poker Chip Values
data:text/html, <style>body{font-size:6rem;font-family:sans-serif;text-align:center;}div{display:inline-block;margin:2rem;width:10rem;height:10rem;line-height:10rem;padding:2rem;border-radius:50%;border:0.5rem solid black;}div+div{background-color:blue;color:white;}div+div+div{background-color:red;}div+div+div+div{background-color:black;}p{text-align:center;}</style><div>25</div><div>50</div><div>100</div><div>500</div><p>Total: $10,000</p>
@colingourlay
colingourlay / README.md
Last active November 23, 2015 14:09
Embeddable widget code preview bookmarklet

Embeddable widget code preview bookmarklet

Quickly preview embeddable widget code such as a Twitter card or Instagram post, before adding it to your website code.

Install

Copy the text of bookmarklet.txt (below) into a new bookmark with a memorable name like "Preview Embed Code" and place it on your bookmarks bar.

Usage

@colingourlay
colingourlay / example.js
Last active August 29, 2015 14:27
Simple unique ids from no-so-unique values
var uniquify = require('uniquifier')();
console.log(uniquify(1));
// > "1"
console.log(uniquify(2));
// > "2"
console.log(uniquify(1));
// > "1_1"
@colingourlay
colingourlay / scottish-tablet-recipe.md
Last active March 3, 2023 05:39
Scottish Tablet Recipe

Scottish Tablet

  • Preparation time: 40 minutes
  • Total time: 3 hours
  • Makes: ~50 portions

Ingredients

  • 1kg caster sugar
  • 250g butter
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}