• This repository has been archived on 28/May/2019
  • Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Python clone of GitHubโ€™s Contributions graph

contribution-graph

This is a clone of the Contributions chart from the GitHub user page, written in Python.

This is what it looks like with the default settings:

I wrote it so that I could use the GitHub design for other things I want to track, including exercise and reading.

The original graph was introduced by GitHub in 2013. I don't know whose idea it was; I just copied the design and built my own version of it.

Installation

Clone this repository onto your computer:

git clone [email protected]:alexwlchan/contributions-graph.git
cd contributions-graph

Install the Python dependencies (I recommend doing this inside a virtualenv):

pip install -r requirements.txt

You also need to build the style sheets. This uses Sass:

sass --scss contributions/static/style.scss:contributions/static/style.css

If you don't want to or can't install Sass, you can also use an online converter, such as Sassmeister.

It should run on Python 2 or 3, although I've only tested it on 2.7.

Usage

Create a text file that records each day, with the number of contributions for that day, with a space between the date and the value:

YYYY-MM-DD value

Other notes:

  • As with Python source code, anything after a # is ignored and treated as a comment.
  • One date/value pair per line.
  • Blank lines are fine.

I've included an example file in the repo: example.txt.

Now use the create_graph() function, supplying the name of this text file, and you get the HTML for a simple page with the contributions graph:

from contributions.render_html import create_graph
print create_graph("example.txt")

If you have multiple such files, supplying them as a list to this function will put all the graphs on the same page:

from contributions.render_html import create_graph
print create_graph(["example1.txt", "example2.txt"])

This should work on Python 2 and 3, but I've only tested it in Python 2.7.

Todo list

Here are some ideas I have for the future:

  • More colours and shapes. Since each cell is just a <div>, it should be fairly easy to recolour and reshape.

    Here are a few that I came up with by just tweaking the CSS by hand:

    It would be nice for those to be available as options rather than by hand-tweaking.

  • A mobile version. The short and wide version doesn't really work on small screens, but I think this design might work if you rotated through 90 degrees. Weeks along the top, months down the side.

    I want to give that a go.

  • Unit tests are awesome. I should write more of them.

  • The ability to customise some of the text. Right now, it only says "Contributions". It would be nice to be able to put other words in as appropriate.

  • More statistics options. I just took the three stats that GitHub offers, but there may be different ones that are useful.

    (For example, a graph of steps walked doesn't really have much use for longest/current streak, but might want average daily steps.)

  • Skippable weekends? I think it might be useful to use this for some work-related tasks, but since I don't work weekends, there would be a bunch of blank boxes. It might be nice to have an option for omitting weekends.

  • Squash the bugs! Since this project involves a lot of fiddly stuff with calendars and dates, it's almost certain that somewhere, someday, something will go wrong. I'd like to do some more testing to find out if/where that's going to be.

More Repositories

1

safari-webarchiver

Save web pages as Safari webarchive files from the command line
Python
107
star
2

dominant_colours

A CLI tool to find the dominant colours in an image ๐ŸŽจ
Rust
89
star
3

notes-export

Export HTML copies of Apple Notes
AppleScript
83
star
4

ao3

A scripted Python interface to some of the data on AO3
Python
75
star
5

docstore

Organising my scanned documents and reference files with keyword tagging
Python
64
star
6

backup-slack

A script for backing up your message history from Slack
Python
64
star
7

asexual

๐Ÿ–ค๐Ÿ’œ Asexual Pride in GitHub repository languages
Crystal
58
star
8

backup-pinboard

Create a local backup of your Pinboard backups
Rust
56
star
9

alexwlchan.net

Source code and plugins for my website, a static site built with Jekyll
Ruby
42
star
10

highlight-twitter-alt-text

Tools to highlight the (in)accessibility of my Twitter timeline
JavaScript
27
star
11

finduntaggedtumblrposts.com

A site for finding untagged Tumblr posts
JavaScript
25
star
12

safari.rs

Command-line utilities for interacting with Safari on macOS
Rust
24
star
13

overcast-downloader

Download the audio files for every podcast you've listened to in Overcast ๐ŸŽง
Python
21
star
14

imessage-archive

Scripts for parsing the iOS message database and getting a useful archive
Python
20
star
15

backup_tumblr

Scripts for backing up your posts, likes and media files from Tumblr
Python
20
star
16

scripts

My collection of helpful scripts, personal tools, and shell config
Python
17
star
17

books.alexwlchan.net

A site to track what I've been reading ๐Ÿ“š
Ruby
15
star
18

handling-http-429-with-tenacity

An example of how to use tenacity to retry HTTP 429 errors in Python
Python
14
star
19

specktre

Make wallpapers from regular tilings of the plane with the Python Imaging Library
Python
13
star
20

junkdrawer

A repo for things that don't have a better place to go
Python
13
star
21

concurrently

A snippet for running multiple, concurrent invocations of a Python function
Python
13
star
22

github-code-search

A proof-of-concept code search for GitHub that de-duplicates results
Python
12
star
23

hurley

Find links between podcasters, a la Kevin Bacon
HTML
12
star
24

python-taskpaper

A Python module for interacting with TaskPaper documents
Python
11
star
25

lazyreader

Lazy reading of file objects for efficient batch processing
Python
10
star
26

backup-instapaper

A script for backing up bookmarks from your Instapaper account
Python
9
star
27

auto_merge_my_pull_requests

A GitHub Action for automatically merging my pull requests on personal repos
Python
9
star
28

get-mobi-cover-image

A script for getting cover images from ebooks in the .mobi format
Python
9
star
29

s3_summary_spreadsheet_script

A script to get a summary spreadsheet of your S3 buckets: how many objects/bytes are in each bucket?
Python
9
star
30

iam-policy-document-tester

Create short-lived, temporary roles for experimenting with AWS IAM policy documents
Python
8
star
31

happybackgrounds

Create simple wallpapers and backgrounds based on Font Awesome icons. For @katef
Python
7
star
32

nextjs-pageweight-analyser

A small script for analysing the page weight and props of Next.js apps
JavaScript
6
star
33

aws-architecture-icon-browser

A web app that lets me search for AWS Architecture Icons by name
Python
6
star
34

blink-photo-reviewer

Reviewing my photos from Photos.app with blink diffs and keyboard shortcuts
Swift
6
star
35

backup-goodreads

A script for backing up reviews from your Goodreads account
Python
5
star
36

tex-dockerfile

The Dockerfile I use to run LaTeX
Dockerfile
5
star
37

ideas-for-inclusive-events

Source code for my list of ideas for running inclusive, accessible and welcoming tech events
SCSS
5
star
38

alfred_shortcuts_github

An Alfred workflow that links to GitHub repos I use regularly
Python
5
star
39

obsidian-simple-gallery

See all the images in your vault
JavaScript
4
star
40

maths-courses

Printed notes for a selection of my university maths courses
4
star
41

uk-station-map

Create a map showing the railway stations you've visited ๐Ÿš‚
CSS
4
star
42

til

Today I Learned
4
star
43

get_live_text

Get text from an image using Apple's built-in "Live Text" feature
Swift
4
star
44

aws_scripts

Scripts for doing useful things in AWS
Python
3
star
45

rainbow-hearts

A web app for generating pride-themed linked hearts ๐ŸŒˆ
Python
3
star
46

scheduled-screenshots

Regular screenshots of the homepage of my website
3
star
47

html-archiver

A Python script for creating a self-contained HTML archive of a webpage
Python
2
star
48

art-from-spanning-trees

Python
2
star
49

library-lookup

Finding books that are available in nearby branches of my public lending library
Python
2
star
50

vocabulary-graph

Experiments in displaying language vocabulary as a graph of related words and phrases
Python
2
star
51

clipatron

A script to automate video clipping using ffmpeg โœ‚๏ธ ๐Ÿ“ผ โœ‚๏ธ
Python
2
star
52

emptydir

Look for empty (or nearly empty) directories and delete them
Rust
2
star
53

filecmp2

Are these two files the same? Explicit file comparisons in Python
Python
1
star
54

alfred-web-links

A script for creating shortcuts for web links/searches in Alfred
Python
1
star
55

imageviewer

Turning a folder of images into a grid I can scroll in my browser
Python
1
star
56

jkr-tweetr

Some tweets for finding tweets about Harry Potter
Python
1
star
57

hot-chocolate

A Python-based static site generator designed for lightweight sites
Python
1
star
58

rainbow-valknuts

A web app for generating pride-themed Norse valknuts ๐ŸŒˆ
Python
1
star
59

detect-use-of-vendored-requests

Detect use of deprecated `from botocore.vendored import requests` in your AWS Lambda functions
Python
1
star
60

create_thumbnail

A simple command-line tool for creating image thumbnails
Rust
1
star
61

snippets

My text expansion snippets for faster typing
Python
1
star