Skip to content

Instantly share code, notes, and snippets.

@wwymak
wwymak / d3Activity.json
Created June 19, 2016 18:43
experiment with d3v4 force layout with d3 repo's activity
[{"id":"4133764903","type":"WatchEvent","actor":{"id":1307603,"login":"akzaidi","display_login":"akzaidi","gravatar_id":"","url":"https://api.github.com/users/akzaidi","avatar_url":"https://avatars.githubusercontent.com/u/1307603?"},"repo":{"id":943149,"name":"d3/d3","url":"https://api.github.com/repos/d3/d3"},"payload":{"action":"started"},"public":true,"created_at":"2016-06-11T18:04:40Z","org":{"id":1562726,"login":"d3","gravatar_id":"","url":"https://api.github.com/orgs/d3","avatar_url":"https://avatars.githubusercontent.com/u/1562726?"}},{"id":"4133691247","type":"WatchEvent","actor":{"id":1904614,"login":"shingchi","display_login":"shingchi","gravatar_id":"","url":"https://api.github.com/users/shingchi","avatar_url":"https://avatars.githubusercontent.com/u/1904614?"},"repo":{"id":943149,"name":"d3/d3","url":"https://api.github.com/repos/d3/d3"},"payload":{"action":"started"},"public":true,"created_at":"2016-06-11T17:03:36Z","org":{"id":1562726,"login":"d3","gravatar_id":"","url":"https://api.github.com/o
@wwymak
wwymak / README.md
Last active May 30, 2016 19:17
experimenting with d3v4 force params
@wwymak
wwymak / .gitignore
Last active March 6, 2016 09:02
weather dashboard expt
node_modules
@wwymak
wwymak / axisUtils.js
Last active February 26, 2016 15:05
reusable d3 chart components, with extra bits and bobs
/**
* Useful stuff for axes
*/
/**
* after drawing the axis, check the label sizes and return the max height and width so you can resize the margins
* if you need to
* @param labelSelArr e.g. d3.selectAll('.y.axis .tick')
*/
function checkLabelSizes(labelSelArr) {
@wwymak
wwymak / README.md
Last active September 11, 2016 11:28
gridmapTest

Work in progress towards making a hexgrid map of the uk --- draw the counties, then assign a circle to each of counties, then use force layout with collision detection to force the circles not to collide

Also draw a hexagon grid, then after force layout has finished, assinged te hexagons closest to the circle to be blue

Add in function so when you click on a colored hexagon, you are 'moving' that to a new position when you click on uncolored hexagon

collision code adapted form http://bl.ocks.org/mbostock/1804919, inspired by https://github.com/kristw/gridmap-layout-thailand

@wwymak
wwymak / project_gutenberg_metadata_parser.py
Created February 21, 2016 20:14
Parses project gutenberg's rdf metadata to something sensible
# -*- coding: utf-8 -*-
"""
script to parse the project gutenberg's rdf catalog into python dict
with option to save to json
most of it from https://gist.github.com/andreasvc/b3b4189120d84dec8857,
tweaked to work with python 3 AND also using lists rather than sets so it is all easily json serialisable
"""
import os
import re
@wwymak
wwymak / README.md
Last active February 18, 2016 23:28
uk_powergen_24hrs
@wwymak
wwymak / eat-to-pret-distance-matrix.csv
Last active February 13, 2016 19:40
eat-to-pret-distance-ldn
InputID TargetID Distance Distance(m)
ChIJZf2Jlc4EdkgRqIM-ef2y6es ChIJXTn0yM4EdkgRSaV_zGoczWw 0.000414318 33.14544047
ChIJM1ObHN8EdkgRx1AtnTH31qI ChIJn02Ng9sEdkgRxFrkfZDwJO0 0.00081524 65.21917804
ChIJX55_pLEEdkgR4Tb2RgSm3tM ChIJJz_dQcoEdkgRGJNfDHFSARc 0.005485031 438.8024655
ChIJhUvcPtwEdkgRT_ZdtjwD7vA ChIJ9xPWINwEdkgRm21aBvx6c4I 0.001029683 82.37464658
ChIJAZyKwNYEdkgRF6IBLG_KdzY ChIJkQ6vidYEdkgR3l8oTFFaHOc 0.001613939 129.1151129
ChIJ78268CsbdkgRhoDFQqqxaaU ChIJLbaLZNEEdkgRkdhk1IC66dM 0.001272168 101.7734658
ChIJZ3p4J8gEdkgRpw9Xd1bY1VE ChIJJz_dQcoEdkgRGJNfDHFSARc 0.005201036 416.0828961
ChIJIUh4NRwQdkgRCiO3lEld7k4 ChIJW3HUgvsPdkgRHVK8WIOke1s 0.01162429 929.9432284
ChIJFZgdDpQPdkgRMEpKpZm8OCs ChIJh2hxb8IPdkgR9eNM6VlzhRw 0.013065664 1045.253151
@wwymak
wwymak / Readme.md
Last active February 5, 2016 16:57
Reusable linechart module

Reusuable linechart component in ES6 based on http://bost.ocks.org/mike/chart/time-series-chart.js, but with check for whether it is a single series or a multiseries

Use like :

let lineplot = linechart.lineplot()
      .width(chartWidth).height(chartHeight)
      .datapointRadius(5)
 .x(d => +d.key)
@wwymak
wwymak / package.json
Created January 27, 2016 10:31
basic node/express setup so you can easily do api requests
{
"name": "app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",