Skip to content

Instantly share code, notes, and snippets.

View jfairbank's full-sized avatar

Jeremy Fairbank jfairbank

View GitHub Profile
### Keybase proof
I hereby claim:
* I am jfairbank on github.
* I am jfairbank (https://keybase.io/jfairbank) on keybase.
* I have a public key ASDzF1DxZgMuEH8gfxrGwrBoVo7g1FOrmERXJBssuwfmhgo
To claim this, I am signing this object:
@jfairbank
jfairbank / instructions.md
Created March 13, 2018 12:58
Build Web Apps with Elm Workshop Instructions

Build Web Apps with Elm Workshop

This workshop uses the wonderful Ellie App for running Elm demos and exercises. Ellie is to Elm what JSBin or JSFiddle is to JavaScript.

All you need is a modern browser such as Chrome or Firefox. Verify your OS and browser can use Ellie by trying to compile this URL: https://ellie-app.com/TPL2qc9ca1/0. I've seen problems with some Linux distros in the past.

For more information and links to the demos and exercises we will use, visit https://github.com/jfairbank/elm-workshop.

@jfairbank
jfairbank / index.css
Created February 6, 2017 21:21
Copy & paste this into your flix application's `App.css` inside `src` to reap the benefits of some style.
body {
margin: 0;
padding: 0;
font-family: sans-serif;
color: #212121;
}
.App-header {
background: #F44336;
}
@jfairbank
jfairbank / movies.json
Created February 6, 2017 21:21
Copy & paste this data into your `movies.json` inside the `src` directory.
[
{
"id": 1,
"name": "The Hateful Eight",
"director": "Quentin Tarantino",
"released": "December 25, 2015",
"image": "http://resizing.flixster.com/TnduRpSjWsBCj88PlUV5Q2dZX0I=/320x474/v1.bTsxMTI4NTM1NDtqOzE3MjE0OzIwNDg7ODEwMDsxMjAwMA",
"description": "Set six or eight or twelve years after the Civil War, a stagecoach hurtles through the wintry Wyoming landscape. The passengers, bounty hunter John Ruth and his fugitive Daisy Domergue, race towards the town of Red Rock where Ruth, known in these parts as The Hangman, will bring Domergue to justice. Along the road, they encounter two strangers: Major Marquis Warren, a black former union soldier turned infamous bounty hunter, and Chris Mannix, a southern renegade who claims to be the town's new Sheriff. Losing their lead on the blizzard, Ruth, Domergue, Warren and Mannix seek refuge at Minnie's Haberdashery, a stagecoach stopover on a mountain pass. When they arrive at Minnie's, they are greeted not by the propr
@jfairbank
jfairbank / example_1.js
Last active September 26, 2017 16:18 — forked from mjc-gh/example_1.js
JavaScript Code Examples
// Question: Explain the difference in how x is defined in these three examples
// Sample A
function a(){
x = 1;
}
// Sample B
function b(){
var x = 1;
@jfairbank
jfairbank / even-numbers-sequence.js
Last active January 24, 2021 16:26
functional streams
const nats = stream(n => n + 1, 1);
const evenNumbers = map(n => n * 2, nats);
console.log(take(10, evenNumbers));
// [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
@jfairbank
jfairbank / git-diff-add.sh
Last active August 29, 2015 14:26
git-diff-add
#!/bin/bash
# git diff a file and then be presented with the option to stage
# the file with "y" or stage a portion with patch via "p"
filepath="${1-.}"
git diff "$filepath"
[[ $? -ne 0 ]] && exit
@jfairbank
jfairbank / fibonacci-generator.js
Last active December 4, 2023 12:23
Fibonacci ES6 Generator
function *fibonacci(n) {
const infinite = !n && n !== 0;
let current = 0;
let next = 1;
while (infinite || n--) {
yield current;
[current, next] = [next, current + next];
}
}
@jfairbank
jfairbank / wrap.js
Last active November 26, 2017 06:22
JS Wrap
function wrap(orig, newDef) {
return function(...args) {
return newDef.apply(this, [orig].concat(args));
};
}
myLib.getTotal = wrap(myLib.getTotal, function(orig, ...args) {
let total = orig.apply(this, args) * 0.8;
return total + this.getTax();
});
@jfairbank
jfairbank / poll-promise.js
Created June 3, 2015 16:23
poll promise
function poll(fn, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
return new Promise(function(resolve, reject) {
(function p() {
// If the condition is met, we're done!
if (fn()) {
resolve();
}