Skip to content

Instantly share code, notes, and snippets.

Jeremy Fairbank jfairbank

Block or report user

Report or block jfairbank

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
@jfairbank
jfairbank / instructions.md
Created Mar 13, 2018
Build Web Apps with Elm Workshop Instructions
View instructions.md

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 Feb 6, 2017 — forked from taylorqj/index.css
Copy & paste this into your flix application's `App.css` inside `src` to reap the benefits of some style.
View index.css
body {
margin: 0;
padding: 0;
font-family: sans-serif;
color: #212121;
}
.App-header {
background: #F44336;
}
@jfairbank
jfairbank / movies.json
Created Feb 6, 2017 — forked from taylorqj/movies.json
Copy & paste this data into your `movies.json` inside the `src` directory.
View movies.json
[
{
"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 Sep 26, 2017 — forked from mjc-gh/example_1.js
JavaScript Code Examples
View example_1.js
// 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;
View even-numbers-sequence.js
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]
View git-diff-add.sh
#!/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 Dec 15, 2018
Fibonacci ES6 Generator
View fibonacci-generator.js
function *fibonacci(n) {
const infinite = !n && n !== 0;
let current = 0;
let next = 1;
while (infinite || n--) {
yield current;
[current, next] = [next, current + next];
}
}
View wrap.js
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();
});
View poll-promise.js
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();
}
@jfairbank
jfairbank / app.js
Last active Sep 26, 2017
ES7 Class Decorators, Properties, and Angular
View app.js
import angular from 'angular';
import MyService from './myService';
import myDirective from './myDirective';
angular.module('myApp', [])
.service('myService', MyService)
.directive('myDirective', myDirective);
You can’t perform that action at this time.