this is the script I used to download and transform the data for this chart https://www.datawrapper.de/_/l4GNH/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('chroma-js/src/io/hex'); | |
require('chroma-js/src/io/lab'); | |
const chroma = require('chroma-js/src/chroma'); | |
console.log(chroma('#cc7d8e').lab()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function area(vertices) { | |
var total = 0; | |
for (var i = 0, l = vertices.length; i < l; i++) { | |
var addX = vertices[i][0]; | |
var addY = vertices[i == vertices.length - 1 ? 0 : i + 1][1]; | |
var subX = vertices[i == vertices.length - 1 ? 0 : i + 1][0]; | |
var subY = vertices[i][1]; | |
total += (addX * addY * 0.5); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function combinations(arr) { | |
var fn = function(active, rest, a) { | |
if (!active.length && !rest.length) | |
return; | |
if (!rest.length) { | |
a.push(active); | |
} else { | |
fn(active.concat(rest[0]), rest.slice(1), a); | |
fn(active, rest.slice(1), a); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
! 8/21/2018, 9:27:26 PM https://www.nytimes.com/ | |
www.nytimes.com###app > div:first-child:-abp-has(> div:-abp-has(> div:-abp-contains(Advertisement))) | |
! 8/21/2018, 9:33:55 PM https://www.nytimes.com/ | |
www.nytimes.com###app > #site-content > div > div > div:-abp-has(> div:-abp-has(> div:-abp-contains(Advertisement))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
needs(dplyr, tidyr, readr, jsonlite) | |
trump_ratings <- read_csv('https://projects.fivethirtyeight.com/trump-approval-data/approval_topline.csv') %>% | |
filter(subgroup=='All polls') %>% | |
mutate(date=as.Date(modeldate, format='%m/%d/%Y'), | |
approve=as.numeric(approve_estimate), | |
disapprove=as.numeric(disapprove_estimate)) %>% | |
select(date, approve, disapprove, president) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function(require) { | |
'use strict'; | |
var d3 = require('d3'); | |
/* | |
* tries to eliminate vertical label overlappings | |
* by slightly moving the labels away from each | |
* other |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const rollup = require('rollup'); | |
const commonjs = require('rollup-plugin-commonjs'); | |
const inputOptions = { | |
input: process.argv[2], | |
plugins: [commonjs()], | |
onwarn: () => {} | |
}; |
I hereby claim:
- I am gka on github.
- I am gka (https://keybase.io/gka) on keybase.
- I have a public key ASA7zDyyCPDyL7H1V6wrKxH56GOVPeaPm1krL33Bual6Pwo
To claim this, I am signing this object:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |