Skip to content

Instantly share code, notes, and snippets.

Avatar

Colin Gourlay colingourlay

View GitHub Profile
@colingourlay
colingourlay / index.css
Last active Aug 1, 2017
Use the fully qualified path of stylesheets you control to discover relative asset paths, no matter where your assets are deployed.
View index.css
[xyz] { content: url(../); }
@colingourlay
colingourlay / index.js
Last active Oct 26, 2016
Using the Y combinator to immutably apply a series of operations to a value, using outputs as inputs. A "Function Centipede", if you will.
View index.js
const Y = f => (x => x(x))(x => f(y => x(x)(y)));
const manufacture = Y(f => x => x.length > 1 ? f([x[1](x[0])].concat(x.slice(2))) : x[0]);
const stage = x => y => manufacture([y].concat(x));
const operations = [
x => x + 1,
x => x * 3,
x => x - 2
];
const transform = stage(operations);
@colingourlay
colingourlay / index.js
Created Oct 25, 2016
requirebin sketch
View index.js
require('pointer-css-variables')(true);
var height;
var nextHeight = window.innerHeight;
window.requestAnimationFrame(function updateHeight () {
if (nextHeight !== height) {
height = nextHeight;
document.documentElement.style.setProperty('--window-inner-height', height);
}
@colingourlay
colingourlay / index.js
Last active Oct 25, 2016
requirebin sketch
View index.js
require('pointer-css-variables')();
// Look at <head> tab to see CSS using variables
// to display coordinates at the cursor
@colingourlay
colingourlay / index.js
Created Oct 7, 2016 — forked from yoshuawuyts/index.js
requirebin sketch
View index.js
const chooet = require('chooet');
const html = require('chooet/html');
chooet(choo => {
app = choo();
app.model({
state: { title: 'Not quite set yet' },
reducers: {
update: (data, state) => ({ title: data })
View index.js
const chooet = require('chooet');
const html = require('chooet/html');
chooet(choo => {
app = choo();
app.model({
state: { title: 'Not quite set yet' },
reducers: {
update: (data, state) => ({ title: data })
View keybase.md

Keybase proof

I hereby claim:

  • I am colingourlay on github.
  • I am colingourlay (https://keybase.io/colingourlay) on keybase.
  • I have a public key whose fingerprint is B491 C16D 2665 A596 4678 1F39 A05D E064 F67F 672F

To claim this, I am signing this object:

@colingourlay
colingourlay / .block
Last active Sep 18, 2016 — forked from mbostock/.block
World Map
We couldn’t find that file to show.
@colingourlay
colingourlay / idle-analytics.js
Created Sep 7, 2016
Defer the standard Google Analytics script until the page is idle, in supported browsers.
View idle-analytics.js
(function(x,y,z){(x[y]&&x[y](z))||z()})(window,'requestIdleCallback',function(){
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-X', 'auto');
ga('send', 'pageview');
});
@colingourlay
colingourlay / index.js
Created Jun 28, 2016
Reduce list of 11 multiple (4) choice question answers to 4 character code, and re-inflate it again.
View index.js
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);