Skip to content

Instantly share code, notes, and snippets.

View odino's full-sized avatar
shipping!

Alessandro Nadalin odino

shipping!
View GitHub Profile
SGVsbG8gd29ybGQK
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!")
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
class DumbMap {
constructor() {
this.list = []
}
get(x) {
let i = hash(x)
if (!this.list[i]) {
return undefined
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
function divide(int) {
int = Math.round(int / 2)
if (int > 10) {
return divide(int)
}
return int
}
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()
class DumbMap {
constructor() {
this.list = []
}
get(x) {
let result
this.list.forEach(pairs => {
if (pairs[0] === x) {
get(x) {
let result
this.list.forEach(pairs => {
if (pairs[0] === x) {
result = pairs[1]
}
})
return result
class DumbMap {
constructor() {
this.list = []
}
...
set(x, y) {
this.list.push([x, y])
}