Skip to content

Instantly share code, notes, and snippets.

@mbostock
mbostock / .block
Last active Dec 9, 2016
Dispatching Events
View .block
license: gpl-3.0
@dannguyen
dannguyen / congress-twitter-data-getter.md
Last active Dec 17, 2016
Who Congress Follows on Twitter data
View congress-twitter-data-getter.md

Find out who Congress follows on Twitter using the command line

Part of a lesson for the Stanford Journalism Computational Methods in the Civic Sphere

This is a short tutorial on how to use command-line tools, including csvfix and t, the command-line Twitter interface, to access and parse data from the Sunlight Foundation and Twitter. The end goal of this exercise is to gather who everyone in Congress follows (friends, in the parlance of Twitter), and then count up the common friends to find out which Twitter accounts are most followed by members of Congress.

Here's a screenshot of the result, after it's been imported into [Google Spreadsheets](https://docs.google.com/spreadsheets/d/1cjRJyrPYj8KAhUrot8ubPOWgbAwm0OqIgPtsswJ2sjM/edit#gid=1358907576

@ramnathv
ramnathv / concaveman.R
Created May 2, 2017
Using Concaveman in R using V8
View concaveman.R
# Using concaveman in R using V8
concaveman <- function(d){
library(V8)
ctx <- v8()
ctx$source('https://www.mapbox.com/bites/00222/concaveman-bundle.js')
jscode <- sprintf(
"var points = %s;var polygon = concaveman(points);",
jsonlite::toJSON(d, dataframe = 'values')
)
ctx$eval(jscode)
View wip-rendering.js
const regl = require('regl')({
extensions: 'OES_texture_float'
})
const LAPLACIAN_SHADER = `
vec4 laplacian (sampler2D img, vec2 id, float DX) {
return -texture2D(img, id) + 0.25 * (
texture2D(img, id + DX * vec2(-1, 0))
+ texture2D(img, id + DX * vec2(1, 0))
+ texture2D(img, id + DX * vec2(0, -1))
View cubeflip.js
/*
The MIT License (MIT)
Copyright (c) 2017 Eric Arnebäck
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@mbostock
mbostock / .block
Last active Jun 17, 2017
Stacked-to-Multiples
View .block
license: gpl-3.0
@mbostock
mbostock / .block
Last active Sep 3, 2017
Concurrent Transitions
View .block
license: gpl-3.0
@avibryant
avibryant / loess.js
Created Aug 17, 2011
Loess smoothing
View loess.js
//adapted from the LoessInterpolator in org.apache.commons.math
function loess_pairs(pairs, bandwidth)
{
var xval = pairs.map(function(pair){return pair[0]});
var yval = pairs.map(function(pair){return pair[1]});
console.log(xval);
console.log(yval);
var res = loess(xval, yval, bandwidth);
console.log(res);
return xval.map(function(x,i){return [x, res[i]]});
@mbostock
mbostock / .block
Last active Sep 12, 2018
TopoJSON Parallax
View .block
license: gpl-3.0
@biovisualize
biovisualize / index.html
Last active Oct 15, 2018
D3.js Reusable Bar Chart with Angularjs
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
font: 14px sans-serif;
}
.axis path, .axis line {
fill: none;