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
aerial | |
android-file-transfer | |
appcleaner | |
atom | |
bbc-iplayer-downloads | |
betterzipql | |
calibre | |
cheatsheet | |
colorpicker-skalacolor | |
disk-inventory-x |
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
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# fpath+=("/usr/local/share/zsh/site-functions") | |
# autoload -U promptinit; promptinit | |
# prompt pure | |
# Path to your oh-my-zsh installation. | |
export ZSH=/Users/oliverjam/.oh-my-zsh | |
# Set name of the theme to load. Optionally, if you set this to "random" |
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 deepCount(arr) { | |
return arr.reduce((acc, item) => { | |
acc += 1; | |
if (Array.isArray(item)) acc += deepCount(item); | |
return acc; | |
}, 0); | |
} | |
const a = [1, [2, 3, [4, 5, 6]]]; |
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
from decimal import getcontext, Decimal | |
getcontext().prec = 20 | |
def calculatePi(): | |
pi = Decimal(3) | |
i = Decimal(2) | |
while i < 20000000: | |
divisor = Decimal(4) / Decimal(i * (i + 1) * (i + 2)) | |
if i % 4 == 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
function calculatePi(dp = 200000) { | |
let pi = 3; | |
let i = 2; | |
while (i < dp) { | |
const divisor = 4 / (i * (i + 1) * (i + 2)); | |
if (i % 4 === 0) { | |
pi -= divisor; | |
} else { | |
pi += divisor; | |
console.log(i + ' ' + pi); |
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 bel = require('bel'); | |
function li(items) { | |
return bel`<ul>${items.map(item => bel`<li>${item}</li>`)}</ul>` | |
} | |
document.body.appendChild(li(['1', '2'])); |
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 loop(start, end, increment) { | |
console.log(start); | |
if (start === end) return; | |
loop(start + increment, end, increment); | |
} | |
loop(0, 10, 1); |
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
// inc :: Number -> (Number,String) | |
const inc = x => y => [y + x, `${inc.name}${x} was called.`]; | |
const inc1 = inc(1); | |
// dec :: Number -> (Number,String) | |
const dec = x => y => [y - x, `${dec.name}${x} was called.`]; | |
const dec1 = dec(1); | |
// unit :: Number -> (Number,String) | |
const unit = x => [x, '']; |
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 get = prop => object => object[prop]; | |
const objects = [ | |
{ id: 1 }, | |
{ id: 2 }, | |
{ id: 3 }, | |
]; | |
objects.map(get('id')); |
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
// pipe takes an arbitrary number of functions as arguments | |
// It returns a new function waiting for a value to be passed in | |
function pipe(...fns) { | |
return function(val) { | |
let finalResult; | |
for (fn of fns) { | |
// Call each function in turn with val (the first time) or the previous result | |
finalResult = fn(finalResult || val); | |
} | |
return finalResult; |