Skip to content

Instantly share code, notes, and snippets.

@nvolungis
Created April 26, 2016 18:00
Show Gist options
  • Save nvolungis/87346c0481b114b269c1503480c5f810 to your computer and use it in GitHub Desktop.
Save nvolungis/87346c0481b114b269c1503480c5f810 to your computer and use it in GitHub Desktop.
# init
accum = [0, 0, ... duration/bucketSize]
display = [0, 0, ... duration/bucketSize]
#when adding a worm / worm change
display = accum.map (viewCount, index) ->
return viewCount if index < worm[0], index > worm[1]
return viewCount + 1
#when ending a worm
worm = [ceil(start/bucketSize), ceil(end/bucketSize)]
accum = accum.map (viewCount, index) ->
return viewCount if index < worm[0], index > worm[1]
return viewCount + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment