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
| 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 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
| 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 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
| 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 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
| # 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 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
| aerial | |
| android-file-transfer | |
| appcleaner | |
| atom | |
| bbc-iplayer-downloads | |
| betterzipql | |
| calibre | |
| cheatsheet | |
| colorpicker-skalacolor | |
| disk-inventory-x |
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
| autoconf | |
| libtool | |
| ruby | |
| automake | |
| libyaml | |
| sqlite | |
| boost | |
| lua | |
| thefuck | |
| cctools |
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 str = "SERR PBQR PNZC"; | |
| function rot13(string) { | |
| return string.split('') | |
| .map(word => { | |
| return word.split('') | |
| .map(letter => { | |
| const letterCode = letter.charCodeAt(0); | |
| if (! (letterCode >= 65 && letterCode <= 90)) return letter; | |
| if (letterCode <= 77) return String.fromCharCode(letterCode + 13); |
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
| function combineStrings() { | |
| let result = ''; | |
| if (arguments.length > 0) { | |
| const args = [...arguments]; | |
| const maxLength = args.map(item => item.length).reduce((a, b) => Math.max(a, b)); | |
| for (let i = 0; i < maxLength; i++) { | |
| args.forEach(item => { | |
| result += item.charAt(i); | |
| }); | |
| } |
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
| function every(arr, f) { | |
| for (let i = 0; i < arr.length; i++) { | |
| if (!f(arr[i])) return false; | |
| } | |
| return true; | |
| } | |
| function some(arr, f) { | |
| for (let i = 0; i < arr.length; i++) { | |
| if (f(arr[i])) return true; |
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
| function average(array) { | |
| function plus(a, b) { return a + b; } | |
| return array.reduce(plus) / array.length; | |
| } | |
| var byName = {}; | |
| ancestry.forEach(function(person) { | |
| byName[person.name] = person; | |
| }); |