This file contains 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
// Adapted from andai.tv/bonsai/ | |
const pipe = (...fns) => (x) => fns.reduce((x, fn) => fn(x), x); | |
// const output = document.getElementById("output"); | |
const ROWS = 30; | |
const COLS = 40; | |
const LIFE = 28; | |
const MAX_BRANCHES = 1024; | |
let branches = 0; |
This file contains 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 compose = (...fns) => (val) => fns.reduceRight((x, fn) => fn(x), val); | |
const sum = (result, item) => result + item; | |
const mult = (a, b) => a * b; | |
function wrap(xf){ | |
return { | |
// 1. We require init as arg, so do not need here | |
init: function(){ | |
throw new Error('init not supported'); |
This file contains 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/bash | |
# targetBranch=${2:-$(git rev-parse --abbrev-ref HEAD)} | |
# echo "target branch is '$targetBranch'" | |
remote=${1:-origin} | |
git remote prune $remote | |
# get remote merged branches | |
git branch -r --merged master | \ | |
# remove master or develop case-insensitive | |
egrep -iv '(master|develop|dev)' | \ | |
# replace remote/ with '' (nothing) |
This file contains 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
// I opened the page one day and wrote the solution on another. I had forgotten it was in the dict/hashmap section... | |
const sum = (acc, next) => acc + next; | |
const matches = (val, i, arr) => { | |
let count = 0; | |
for (++i; i < arr.length; i++) { | |
if (val == arr[i]) count++; | |
} | |
return count; | |
}; |
This file contains 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
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
type Fetcher interface { | |
// Fetch returns the body of URL and | |
// a slice of URLs found on that page. |
This file contains 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
/** | |
* @param {number} prev | |
* @param {number} next | |
* @return {number} the sum of prev and next | |
*/ | |
const add = (prev, next) => prev + next; | |
/** | |
* Generate index pair combinations, arr.length choose 2 | |
* @param {array} arr |
This file contains 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
/** | |
* @param {array} arr array to insert into | |
* @param {number} i index for insertion | |
* @param {object} val value to be inserted | |
* @return {array} a new array with val inserted at i | |
*/ | |
const insert = (i, arr, val) => [...arr.slice(0, i), val, ...arr.slice(i)]; | |
/** | |
* @param {string} |
This file contains 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
(function farAway() { | |
const me = { | |
about: 'Famous musician, looks like Buddy Holly', | |
birthday: new Date('June 13, 1970'), | |
hobbies: ['knitting'], | |
favoriteFood: 'burnt lamb', | |
} | |
let you = { | |
are: function (attr) {return Object.assign({},this, attr)} | |
know: function (subject) { this.knows.push(subject); } |
This file contains 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
(function MrGreen() { | |
class Person { | |
constructor () { | |
this.feeling = 5; | |
this._love = null; | |
} | |
get love() { return this._love; } | |
set love(person) { | |
this._love = person; |
This file contains 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
(function Opera() { | |
const pipe = (...fns) => (x) => fns.reduce((v, f) => f(v), x); | |
const open = (obj = {}) => Object.assign({}, obj, {open: true}); | |
const lookUpTo = (target) => (obj) => | |
Object.assign({}, obj, {lookingAt: target}); | |
const see = (obj) => Object.assign({}, obj, {canSee: true}); | |
if (isRealLife || isFantasy) { |