const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args)));
const pipe = (...fns) => compose.apply(compose, fns.reverse());
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The Babylonian Method | |
// http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method | |
// @param n - the number to compute the square root of | |
// @param guess - the best guess so far (can omit from initial call) | |
function squirt(n, guess) { | |
if (!guess) { | |
guess = n / 2.0; // Take an initial guess at the square root | |
} | |
const divided = n / guess; // Divide our guess into the number | |
const newGuess = (divided + guess) / 2.0; // Use average of guess and divided as our new guess |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const traceFn = (fn, context) => function () { | |
console.trace(`${fn.name} called with arguments: `, arguments); | |
return fn.apply(context || this, arguments); | |
} | |
console.log = traceFn(console.log); | |
console.log('foo'); | |
//>> log called with arguments: ["foo"] | |
//>> (anonymous) @ VM98:2 | |
//>> (anonymous) @ VM138:2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set variables in .bashrc file | |
# don't forget to change your path correctly! | |
export GOPATH=$HOME/golang | |
export GOROOT=/usr/local/opt/go/libexec | |
export PATH=$PATH:$GOPATH/bin | |
export PATH=$PATH:$GOROOT/bin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
"United States" => "us", | |
"Afghanistan" => "af", | |
"Albania" => "al", | |
"Algeria" => "dz", | |
"American Samoa" => "as", | |
"Andorra" => "ad", | |
"Angola" => "ad", | |
"Anguilla" => "ai", | |
"Antarctica" => "aq", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('jekyll', function(){ | |
return require('child_process').spawn('jekyll', ['serve', '--watch'], { stdio: 'inherit' }); | |
}); | |
gulp.task('default', ['jekyll']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This is usually run by the d_install script (https://gist.github.com/treall/240b8408cd944c17551a) | |
# This script will: | |
# make sure you're in the correct directory, | |
# download the latest drupal 7 release, | |
# install our frequently used modules, | |
# setup the admin account, | |
# create an Aurora subtheme, | |
# update the .htaccess file for use on our outdated dev server, |