Skip to content

Instantly share code, notes, and snippets.

@brito
Last active September 24, 2018 16:07
Show Gist options
  • Save brito/65867747bdc3a0ce9acf7cbbba98d564 to your computer and use it in GitHub Desktop.
Save brito/65867747bdc3a0ce9acf7cbbba98d564 to your computer and use it in GitHub Desktop.
number generator from continuous fraction of timestamp
//codegolf.stackexchange.com/a/79490/69502
continuous_fraction = f = (n,d) => n%d ? [r=(n/d)|0,...f(d,n-r*d)] : [n/d]
bars = n => console.debug(n, Array(n).fill('|').join(''))
interval =
setInterval(() => {
requestAnimationFrame(() => {
now = new Date
a = ~now
b = ~~now
indices = continuous_fraction(+now, b)
console.log(+now, b, a, b+a, indices)
indices.slice(1).forEach(bars)
})
}, 1e3)
max = 5
cheapo_limiter =
setInterval(() => !--max ?
[interval, cheapo_limiter]
.map(clearInterval) : 0, 1e3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment