Skip to content

Instantly share code, notes, and snippets.

View jbreckmckye's full-sized avatar

Jimmy Breck-McKye jbreckmckye

View GitHub Profile
jbreckmckye / Knockout foreachSorted
Last active August 29, 2015 14:07
Knockout simple sorted forEach
<!DOCTYPE html>
<script src="//"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<h4>Simple foreach</h4>
<ul data-bind="foreach: names">
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
jbreckmckye / monads.markdown
Last active April 18, 2016 21:35
Old monad tutorial
layout title date comments categories
The gist of monads
2016-04-07 00:47:16 +0100
functional programming

Most monad tutorials are long, confusing, and ineffective. I cannot promise this one will be more clear, more interesting, or even more effective, but I can at least promise to make it brisk. You have nothing to lose by reading it.

var myFileName = 'commercial.js';
var fs = require('fs');
var input = fs.createReadStream(myFileName);
var text = '';
input.on('data', function (data) {
text += data;

What I am changing

This PR fixes a bug in the settings/motivations page:


Presently, it isn't possible to change the motivation more than once per page load. On the second change, we throw an exception:

vendors.min.js:9 Raven: Exception TypeError: Cannot convert undefined or null to object
'use strict';
module.exports = function compileJS(grunt) {
const babel = require('babel-core'),
Concat = require('concat-with-sourcemaps'),
config = grunt.config.get('tt'),
configHelper = require('../tt/config.js'),
fileSeparator = ';\n',
fs = require('fs'),
path = config.get('dir.public') + '/js',
jbreckmckye /
Created January 25, 2017 10:05
Get rid of that stupid single-var-declaration rule, once and for all

I don't like the single-var rule.

It annoys me for several reasons.

As a declaration grows, it becomes ambiguous

Here's a slice of code. What does it signify?

 peter: payPeter().toRob('paul'),
jbreckmckye / module.js
Created April 11, 2017 21:15
Self-instantiating module constructors
function Module(lodash, THREE, moment) {
this.thingy = stuff =>, false);
this.majig = whatever => moment().format(whatever);
this.zxzzxz = blah => new THREE.TextureLoader().load(blah);
module.exports = new Module(
jbreckmckye / selenium-js-example.js
Created April 19, 2017 09:20
Simple script to start up Chrome with Selenium, run an operation, take a screenshot and exit
const fs = require('fs');
const selenium = require('selenium-standalone');
const webdriver = require('webdriverio');
function installSelenium() {
jbreckmckye / bundle.js
Created June 14, 2017 12:02
Bundle files from the internet into a local zip
let fs = require('fs');
let archiver = require('archiver');
let request = require('request');
let archive = archiver('zip', { store: true});
let out = fs.createWriteStream(__dirname + '/');
let sport1 = request('');
let sport2 = request('');