Skip to content

Instantly share code, notes, and snippets.

View leondutoit's full-sized avatar

Leon du Toit leondutoit

View GitHub Profile
@leondutoit
leondutoit / userinfo-signed-jwt.py
Last active May 11, 2021 09:20
pseudo-code for returning claims from userinfo endpoint as a signed JWT
"""
Pseudocode for implementing returning claims obtained from the /userinfo
OIDC endpoint, as a signed JWT. The spec describes this here:
https://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse
"If the UserInfo Response is signed and/or encrypted, then the Claims are
returned in a JWT and the content-type MUST be application/jwt."
@leondutoit
leondutoit / example.R
Last active January 15, 2016 08:46
multiple timeseries ggplot
# install dependencies
options(repos = 'https://cran.rstudio.com/')
install.packages('ggplot2')
# read example data
data <- read.csv('tsdata.csv', colClasses = c('Date', 'numeric', 'character'), stringsAsFactors = FALSE)
# load library and make a timeseries plot
library(ggplot2)
ggplot(data, aes(date, val, colour=label)) + geom_line()
@leondutoit
leondutoit / sqlite_intro.sql
Last active April 5, 2021 11:06
sqlite things
-- this is a random comment
-- anything prefixed by two dashes is a comment
-- and will not be executed by the database
-- to start the interactive session on the command prompt
-- type: $ sqlite3
-- something will be printed and then you'll see another prompt like this
-- sqlite>
@leondutoit
leondutoit / README.md
Last active May 28, 2019 02:48
Norwegian parliamentary voting patterns

Holder de Ord (Norwegian for "keep their word") does information work by using and analysing parliamentary voting data. At the start of a new electoral cycle, parties declare their policy intentions to their voters. Are they really doing what they said they would? How are voting patterns influenced when parties form coalitions? Which are the most divisive issues in parliament? These are all important questions that are typically difficult to anwer without spending hours on research.

This visualisation presents a sample of voting data showing to what degree different party combinations voted in the same way on a set of issues. Neither the combinations nor the issues are exhaustive. Rather, the visualisation is a proof of concept of how such a presentation can help answer the types of questions mentioned above. A simple mouseover provides an explanatory note to the investigator.

@leondutoit
leondutoit / README.md
Last active December 22, 2015 13:59
World economic growth

A simple representation of the yearly increase and descrease of real per person GDP from 1960 to 2011. The visualisation shows whether a country had positive of negative growth in a particular year. Dark blue means positive growth while light blue means negative. White indicates that no observation was available for that year.

The data source is the Penn World Tables. Each country's GDP is converted into US Dollar terms (2005 constant prices) using Purchasing Power Parity weighting. The conversion to real terms allows us to see changes in volumes over time, while the conversion to USD using PPP allows for a common unit of expression. This common unit of expression, although underpinned with many assumptions and measurement errors, makes it more realistic to compare living standards between different countries.

Note how 2009, the year after the global financial crisis, is coloured

@leondutoit
leondutoit / README.md
Last active December 22, 2015 07:18
Unemployment ranked with horizontal bars

Here is a simple, mildly interactive visualisation of unemployment in the world. More specifically, a ranked list of the 20 countries with the highest unemployment rates. The design draws heavily from Mike Bostock's bar chart used in his explanation of object constancy.

The data was downloaded in Excel format from the World Bank. As the notes explain, unemployment is narrowly defined as people who are available to work and who have actively been engaged in looking for work. I say "narrow" because in many cases it is not quite clear how long this window should be, or to what extent it is relevant to the problem.

Lastly, the data is from 2010 and the world has changed quite rapidly since then. Anyways, this at least shows some interestng data in addition to how to make a graph like this. Enjoy :)

@leondutoit
leondutoit / README.md
Last active December 19, 2015 09:09
Tufte-style slopegraph

The South African economy has undergone much change since 1980. At a macroeconomic level this is noticable in the change in the contributions of different sectors of production to GDP. Like many other emerging markets, the economy has gradualy shifted to a more services-based economy.

In this visualisation I show this using a graphical technique pioneereed by Edward Tufte - a slopegraph. There are some basic mouseover interactions to help the eye see and the brain understand.

@leondutoit
leondutoit / README.md
Last active December 19, 2015 07:19
Interactive verse

Just one of my favourite quotes from The Dhammapada. With some mouseover and mousedown interaction.

@leondutoit
leondutoit / README.md
Last active December 19, 2015 03:08
The Grumpy Cat

A data driven grumpy cat

Because the Internet is made of cats. Because The Grumpy Cat is a legend. And because transforming my drawings into d3 with Python is just too much fun.

There is certainly no d3 magic here - it's all in the data: 812,578 svg circles that is. Maybe this even qualifies for a big data grumpy cat?