News for hackers. Stuff that matters.
Re:Ask HN: How much coffee do you drink as a programmer? by mfontani on Saturday April 25, 2020 @04:37AM (#22976659)
A while back (couple years) I started tracking how much coffee I drank, and (roughly) when.

I created a simple Mojolicious webapp, putting data on a SQLite database. I later expanded it to accept/use an "API key" with which I could track my coffee intake, or get how much I drank already and when was my last cup, "simply" by running a simple bash+curl script. The site, instead, displays a neat github-commits-like chart[1] and some recent stats. I have a branch which changes the code to work on Postgres and is deployable on dokku, but I've not yet made the switch to that. I'm still using a mojolicious+sqlite+hypnotoad process running on a cheap VPS.

Since I started tracking my intake, it looks like I drank, on average, 3-4 coffees per day:

    sqlite> select (select count(*) from intake)/(select julianday(max(time_t)) - julianday(min(time_t)) from intake);
    3.7864677548175
Here in Italy's northern region, the quarantine started region-wide on the 8th of March.

    sqlite> select (select count(*) from intake where time_t > "2020-03-08")/(select julianday(max(time_t)) - julianday("2020-03-08") from intake);
    4.20309898028925
It looks like I'm drinking a bit more coffee than the usual, but surely nowhere as near as my most intake:

    sqlite> select date(time_t) as ymd, count(*) as cnt from intake group by ymd order by cnt desc limit 5;
    2018-05-16|11
    2018-03-12|10
    2018-05-15|10
    2018-02-07|9
    2019-06-04|9
Hope it helps! :)

[1]: https://i.imgur.com/c0DqAGO.png

Re:Ask HN: How much coffee do you drink as a programmer? by galesky on Saturday April 25, 2020 @08:53AM (#22977717)
That's so overkill and so cool at the same time, a super engineer behavior lol. Nice job!
Re:Ask HN: How much coffee do you drink as a programmer? by geoah on Saturday April 25, 2020 @06:21PM (#22982104)
That is amazing. Do you happen to have published the source for this somewhere?
Re:Ask HN: How much coffee do you drink as a programmer? by mfontani on Sunday April 26, 2020 @06:53AM (#22986198)
I need to clean a few things up before being able to do so, chief among them my initial rookie mistake to name the users table "user", which in retrospect wasn't a good idea when moving the thing to Postgres - so while I've got a neat little "migrations.sql" that has served me fine over the various versions, it just can't work when ran against Postgres.

I'll fix it up in the next few days and will reply in a comment once it's available.

Re:Ask HN: How much coffee do you drink as a programmer? by temikus on Sunday April 26, 2020 @03:42AM (#22985341)
Not the OP but if you like recording personal statistics, you might like http://reporter-app.com/. I've been using it for personal experiments a bunch of times (like measuring stress levels).