Skip to content

Instantly share code, notes, and snippets.

Avatar
shipping!

Alessandro Nadalin odino

shipping!
View GitHub Profile
View build-remover.abs
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!")
View wa.js
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
View h.js
class DumbMap {
constructor() {
this.list = []
}
get(x) {
let i = hash(x)
if (!this.list[i]) {
return undefined
View h.js
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
View h.js
function divide(int) {
int = Math.round(int / 2)
if (int > 10) {
return divide(int)
}
return int
}
View h.js
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()
View h.js
class DumbMap {
constructor() {
this.list = []
}
get(x) {
let result
this.list.forEach(pairs => {
if (pairs[0] === x) {
View h.js
get(x) {
let result
this.list.forEach(pairs => {
if (pairs[0] === x) {
result = pairs[1]
}
})
return result
View h.js
class DumbMap {
constructor() {
this.list = []
}
...
set(x, y) {
this.list.push([x, y])
}
You can’t perform that action at this time.