Skip to content

Instantly share code, notes, and snippets.

@ZeroDragon
Last active December 15, 2015 18:30
Show Gist options
  • Save ZeroDragon/aaa13f71ca6d948aef33 to your computer and use it in GitHub Desktop.
Save ZeroDragon/aaa13f71ca6d948aef33 to your computer and use it in GitHub Desktop.
The most useless script ever!
argsarr = process.argv[2..]
args = {}
for i,k in argsarr
if k%2 is 0
args[i.replace(/--/,'')] = ~~argsarr[k+1]
log = (text)->
if process.stdout
process.stdout.clearLine()
process.stdout.cursorTo 0
process.stdout.write text
else
console.log text
class Brew
empty : true
content : 0
size : 0
refill : ->
@content = @size
@empty = false
drink : ->
@content--
@empty = true if @content is 0
constructor : (qty)->
@size = qty
@refill()
cups = 1
coffee = new Brew args.size
timer = setInterval ->
if coffee.empty
log "Time to get more coffee!!!"
cups++
coffee.refill()
else
coffee.drink()
log "☕ x#{cups} Ahhh... warm coffee #{coffee.content}/#{coffee.size}"
,args.interval * 1000
@ZeroDragon
Copy link
Author

run it with

$> coffee coffee.coffee --interval <time in seconds> --size <any positive int>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment