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
SGVsbG8gd29ybGQK |
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
token = env("GH_TOKEN") | |
no_more_repos = false | |
page = 1 | |
while !no_more_repos { | |
repos = `curl -s -H "Authorization: token $token" "https://api.github.com/orgs/namshi/repos?page=$page&type=private"`.json() | |
if !repos.len() { | |
no_more_repos = true | |
echo("End of repositories!") |
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
a=new AudioContext() // browsers limit the number of concurrent audio contexts, so you better re-use'em | |
function beep(vol, freq, duration){ | |
v=a.createOscillator() | |
u=a.createGain() | |
v.connect(u) | |
v.frequency.value=freq | |
v.type="square" | |
u.connect(a.destination) | |
u.gain.value=vol*0.01 |
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
class DumbMap { | |
constructor() { | |
this.list = [] | |
} | |
get(x) { | |
let i = hash(x) | |
if (!this.list[i]) { | |
return undefined |
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
let m = new DumbMap() | |
for (x = 0; x < 1000000; x++) { | |
m.set(`element${x}`, x) | |
} | |
console.log(m.get('element0')) // 999988 | |
console.log(m.get('element1')) // 999988 | |
console.log(m.get('element1000')) // 999987 |
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 divide(int) { | |
int = Math.round(int / 2) | |
if (int > 10) { | |
return divide(int) | |
} | |
return int | |
} |
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
let m = new DumbMap() | |
m.set('x', 1) | |
m.set('y', 2) | |
console.time('with very few records in the map') | |
m.get('I_DONT_EXIST') | |
console.timeEnd('with very few records in the map') | |
m = new DumbMap() |
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
class DumbMap { | |
constructor() { | |
this.list = [] | |
} | |
get(x) { | |
let result | |
this.list.forEach(pairs => { | |
if (pairs[0] === 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
get(x) { | |
let result | |
this.list.forEach(pairs => { | |
if (pairs[0] === x) { | |
result = pairs[1] | |
} | |
}) | |
return result |
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
class DumbMap { | |
constructor() { | |
this.list = [] | |
} | |
... | |
set(x, y) { | |
this.list.push([x, y]) | |
} |
NewerOlder