Skip to content

Instantly share code, notes, and snippets.

View trebor's full-sized avatar

Robert Harris trebor

  • Sam Clam's Disco
View GitHub Profile
import React, { useRef, useEffect } from "react";
import { select } from "d3-selection";
import useComponentSize from "@rehooks/component-size";
const D3Svg = ({
data,
initialize = () => {},
margin = {
top: 0,
empty
import { atom, selector } from "recoil";
export const getUrlParam = (name, defaultValue, setIfUnset = false) => {
const setValue = new URL(window.location).searchParams.get(name);
if (setIfUnset && !setValue) setUrlParam(name, defaultValue);
return setValue || defaultValue;
};
export const setUrlParam = (name, value, title = document.title) => {
const { protocol, host, pathname } = window.location;
@trebor
trebor / data.csv
Created November 14, 2019 01:34 — forked from d3noob/data.csv
Simple line graph with v4
date close
1-May-12 58.13
30-Apr-12 53.98
27-Apr-12 67.00
26-Apr-12 89.70
25-Apr-12 99.00
24-Apr-12 130.28
23-Apr-12 166.70
20-Apr-12 234.98
19-Apr-12 345.44
@trebor
trebor / energy.json
Last active April 25, 2019 23:49
modified-energy-data
[
{"source":"Agricultural Energy Use","target":"Carbon Dioxide","value":"1.4"},
{"source":"Agriculture","target":"Agriculture Soils","value":"5.2"},
{"source":"Agriculture","target":"Livestock and Manure","value":"5.4"},
{"source":"Agriculture","target":"Other Agriculture","value":"1.7"},
{"source":"Agriculture","target":"Rice Cultivation","value":"1.5"},
{"source":"Agriculture Soils","target":"Nitrous Oxide","value":"5.2"},
{"source":"Air","target":"Carbon Dioxide","value":"1.7"},
{"source":"Aluminium Non-Ferrous Metals","target":"Carbon Dioxide","value":"1.0"},
{"source":"Aluminium Non-Ferrous Metals","target":"HFCs - PFCs","value":"0.2"},
@trebor
trebor / shootings.csv
Created June 28, 2018 21:52
Mother Jones - Mass Shootings Database, 1982 - 2018
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 24 columns, instead of 18. in line 1.
case,location,date,summary,fatalities,injured,total_victims,venue,age of shooter,prior signs of mental health issues,mental health - details,weapons obtained legally,where obtained,type of weapons,weapon details,race,gender,sources,mental health sources,sources (additional - age),latitude,longitude,type,year
Santa Fe High School shooting,"Santa Fe, TX",5/18/18,"Dimitrios Pagourtzis, a 17-year-old student, opened fire at Santa Fe High School with a shotgun and .38 revolver owned by his father; Pagourtzis killed 10 and injured at least 13 others before surrendering to authorities after a standoff and additional gunfire inside the school. (Pagourtzis reportedly had intended to commit suicide.) Investigators also found undetonated explosive devices in the vicinity. (FURTHER DETAILS PENDING.)",10,13,23,School,17,-,-,-,Father's weapons,shotgun; .38 revolver,-,White,M,https://www.chron.com/news/houston-texas/article/Shots-fired-at-Santa-Fe-High-School-12925050.php; https://www.nytimes.com/2018/05/18/us/school-shooti
@trebor
trebor / .block
Created December 3, 2017 19:53
Sankey with Minard dots for different link types
license: mit