Giter Club home page Giter Club logo

100-blocks's Introduction

100 Blocks - Activity Tracking and Visualization

Inspired by the Tim Urban blog post entitled "100 Blocks a Day," I created a Messenger bot to poll me every 10 minutes about what I'm doing, and a couple python scripts to visualize my "100 Blocks" at the end of the day. You can read more about it in my blog post.

Setup

Follow the tutorial at Quick Start - Messenger Platform, except use the starter code inside the messenger-webhook directory of this repository instead of the provided starter code. In your deploy environment (such as Heroku,) specify the environment variables required by the webhook such as PAGE_ACCESS_TOKEN and VERIFY_TOKEN (the latter of which is a random string.) Finally, you'll have to create a table in DynamoDB that has "activity" as its primary index and "timestamp" as its sort index, and replace DYNAMODB_TABLE_NAME and DYNAMODB_TABLE_REGION with the appropriate values.

Visualization in Python (perhaps in Jupyter) can be run as follows You'll first need to configure your AWS credentials locally. Then, from the visualization directory, run pip install -r requirements.txt, load the data from DynamoDB into a Pandas table, and extract 10-minute blocks from the data:

from datetime import datetime, timedelta
from pytz import timezone

from utils import load_dynamo_table, extract_blocks
from config import DYNAMODB_TABLE_NAME, ACTIVITY_COLORS
# lower bound on wakeup time (that way only get activities after sleep)
this_morning_naive = datetime.now().replace(
    hour=9, minute=0, second=0, microsecond=0
)
# convert to an "aware" datetime object (has a sense of timezone)
eastern = timezone('US/Eastern')
this_morning_aware = eastern.localize(this_morning_naive)
start_dt = this_morning_aware
end_dt = this_morning_aware + timedelta(days=1)
df = load_dynamo_table(DYNAMODB_TABLE_NAME,
                       start_dt=start_dt,
                       end_dt=end_dt)
blocks = extract_blocks(df)

Classic "100 Blocks" visualization:

from hundred_blocks_viz import hundred_blocks_viz
hundred_blocks_viz(blocks, ACTIVITY_COLORS, day=start_dt)

Pie chart of your activities visualization:

from pie_chart_viz import pie_chart_viz
pie_chart_viz(blocks, ACTIVITY_COLORS, day=start_dt)

Some more example usages can be seen in viz_experiments Jupyter notebook. Not always using the most efficient ways to do things, but I'll get around to cleaning it up.

100-blocks's People

Contributors

ketan0 avatar

Stargazers

Martin Borbola avatar Phil Wornath avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.