Skip to content

Instantly share code, notes, and snippets.

Derek Swingley swingley

Block or report user

Report or block swingley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View macys.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@swingley
swingley / population-poverty.html
Created Jun 24, 2017
Retrieve data from the Census API, build a table with D3.
View population-poverty.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var stats = 'B01001_001E,B17001_002E';
@swingley
swingley / cereal.csv
Last active Mar 22, 2017
Cereal Scatterplot
View cereal.csv
Cereal Name Manufacturer Type Calories Protein (g) Fat Sodium Dietary Fiber Carbs Sugars Display Shelf Potassium Vitamins and Minerals Serving Size Weight Cups per Serving
100%_Bran Nabisco C 70 4 1 130 10 5 6 3 280 25 1 0.33
100%_Natural_Bran Quaker Oats C 120 3 5 15 2 8 8 3 135 0 1 -1
All-Bran Kelloggs C 70 4 1 260 9 7 5 3 320 25 1 0.33
All-Bran_with_Extra_Fiber Kelloggs C 50 4 0 140 14 8 0 3 330 25 1 0.5
Almond_Delight Ralston Purina C 110 2 2 200 1 14 8 3 -1 25 1 0.75
Apple_Cinnamon_Cheerios General Mills C 110 2 2 180 1.5 10.5 10 1 70 25 1 0.75
Apple_Jacks Kelloggs C 110 2 0 125 1 11 14 2 30 25 1 1
Basic_4 General Mills C 130 3 2 210 2 18 8 3 100 25 1.33 0.75
Bran_Chex Ralston Purina C 90 2 1 200 4 15 6 1 125 25 1 0.67
View va_ratings.js
var xhr = new XMLHttpRequest();
xhr.addEventListener('load', function(e) { window.vaData = e.target.response; });
xhr.open('get', 'data/68.json');
xhr.send();
vaData = JSON.parse(vaData);
vaData.table_data.values.forEach(function(row) { row.forEach(function(d, dIndex) { if ( d.indexOf && d.indexOf(',') > -1 ) { row[dIndex] = '"' + d + '"'; } }) });
var rows = vaData.table_data.values.map(function(row) { return row.join(','); });
copy(vaData.table_data.fields.join(','));
// paste to gist
copy(rows.join('\n'));
View va_ratings.csv
VA Medical Center or System City State 12/31/2015 Star Rating (4th qtr) 6/30/2016 Star Rating (2nd qtr)
Phoenix VA Health Care System Phoenix Arizona 1 1
Southern Oregon - White City VA Rehabilitation Center & Clinics White City Oregon 1 1
Memphis VA Medical Center Memphis Tennessee 1 1
Tennessee Valley Healthcare System - Nashville VA Medical Center Nashville Tennessee 1 1
Tennessee Valley Healthcare System - Alvin C. York Campus Murfreesboro Tennessee 1 1
Dallas VA Medical Center Dallas Texas 1 1
El Paso VA Medical Center El Paso Texas 1 1
VA Greater Los Angeles Healthcare System Los Angeles California 2 1
John D. Dingell VA Medical Center Detroit Michigan 2 1
View state-abbr-to-fips.json
{
"AL": "01",
"AK": "02",
"AS": "60",
"AZ": "04",
"AR": "05",
"CA": "06",
"CO": "08",
"CT": "09",
"DE": "10",
View san-diego-tacomainia-2016.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mercator projection</title>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
body {
background-color: gray;
margin: 1em auto;
@swingley
swingley / gist:6f99328071c10fb53598
Created Jan 18, 2016
Bookmarklet that tries to go from github repo to associated gh-pages. The opposite of https://gist.github.com/swingley/5807614.
View gist:6f99328071c10fb53598
javascript:(function() {var w = window.location;var p = w.pathname.split('/');window.location='http://'+p[1]+'.github.io/'+p[2]+'/';})();
View wa-or-id.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.