Skip to content

Instantly share code, notes, and snippets.

Callum Macrae callumacrae

Block or report user

Report or block callumacrae

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
callumacrae / .block
Last active Apr 13, 2018 — forked from mbostock/.block
World Map
View .block
license: gpl-3.0
View invisible-page.js
import { keymap } from './keypress-promise';
// import CrapEventEmitter from './crap-event-emitter';
const page = {
id: 'page',
speech: 'voiceover-demo, web content',
children: [
id: 'main-heading',
speech: 'heading level 1, Example page',
callumacrae / .block
Last active Mar 8, 2017 — forked from mbostock/.block
Threshold Choropleth
View .block
license: gpl-3.0
callumacrae / .block
Last active Mar 8, 2017 — forked from mbostock/.block
Area Choropleth
View .block
license: gpl-3.0
View gulpfile.js
const gulp = require('gulp');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const webpackConfig = require('./webpack.config.js');
gulp.task('js:build', function (done) {
webpack(webpackConfig('js:build'), function (err, stats) {
if (err) {
throw err;
View sass-npm-importer.js
'use strict';
var path = require('path');
var findup = require('findup-sync');
var cache = {};
function sassNpmImporter(url, prev, done) {
// Fall back to old URL
var newUrl = url;
View index.js
import './module2';
// Output will be "module two" followed by "module one"
View Unique.hs
import Data.List (foldl1')
-- Factorial function
fact n = foldl1' (*) [1..n]
-- Permutation function
n `p` 0 = 1
n `p` 1 = n
n `p` r = foldl1' (*) [n-r+1..n]
View gist:73c69c72d95ecdedfcc4
Started GET "/cart" for ::1 at 2015-09-22 17:35:39 +0100
Processing by Mermaid::CartController#show as HTML
Spree::User Load (0.3ms) SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."id" = $1 LIMIT 1 [["id", 1]]
Cache read: spree/app_configuration/supported_currencies
Spree::Order Load (0.2ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."user_id" = $1 AND "spree_orders"."guest_token" = $2 AND "spree_orders"."currency" = $3 LIMIT 1 [["user_id", 1], ["guest_token", "6NRkTjAVAUKRiHh3K6AeLw"], ["currency", "GBP"]]
Cache read: spree/app_configuration/supported_currencies
CACHE (0.0ms) SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."id" = $1 LIMIT 1 [["id", 1]]
Spree::LineItem Load (0.3ms) SELECT "spree_line_items".* FROM "spree_line_items" WHERE "spree_line_items"."order_id" = $1 ORDER BY spree_line_items.created_at ASC [["ord
callumacrae / gist:5c21f1ae3fdef948316f
Last active Sep 3, 2015
Using service workers to mitigate the affect of a failing SPOF
View gist:5c21f1ae3fdef948316f
We have a blocking script (Optimizely) in the head of our website that we have no control over and
cannot move to the footer. If this script were to somehow go down, then our site would effectively
go down, too. I was thinking about measures we could take so that if Optimizely does go down, it
doesn't take our site with it. One possible approach could be to use service workers.
36.4% of our traffic supports service workers. 28% of that is returning visitors, and will already
have the service worker installed (this is important; the service worker would be installed after
the potential failing script). That's 2700 visitors a day. We can use service workers on these
browsers to detect when Optimizely is down or very slow, and let the server know via an AJAX request.
You can’t perform that action at this time.