Skip to content

Instantly share code, notes, and snippets.

View peterbsmyth's full-sized avatar

Peter B Smith peterbsmyth

View GitHub Profile
@peterbsmyth
peterbsmyth / data.json
Created April 24, 2015 16:42
Stacked Bar Chart with Mouseover Effect
[
{
"date": "2015-04-18T04:00:00.000Z",
"events": 11,
"duration": {
"zazen": "1990-09-13T04:00:00.000Z",
"work": "1990-09-13T06:45:00.000Z",
"social": "1990-09-13T08:00:00.000Z",
"learn": "1990-09-13T04:00:00.000Z",
"bike": "1990-09-13T05:30:00.000Z",
@peterbsmyth
peterbsmyth / France2012.tsv
Last active August 29, 2015 14:25
Udacity D3 Project
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 41 columns, instead of 38. in line 5.
Year Div Date HomeTeam AwayTeam FTHG FTAG FTR HTHG HTAG HTR HS AS HST AST HF AF HC AC HY AY HR AR B365H B365D B365A BWH BWD BWA IWH IWD IWA LBH LBD LBA WHH WHD WHA VCH VCD VCA
2012 France 06/08/2011 Ajaccio Toulouse 0 2 A 0 1 A 18 13 6 8 14 17 11 4 4 2 0 0 2.63 3.00 2.88 2.60 2.95 2.80 2.50 3.00 2.70 2.60 3.00 2.60 2.60 3.00 2.88 2.63 3.10 3.00
2012 France 06/08/2011 Brest Evian Thonon Gaillard 2 2 D 2 2 D 23 9 7 3 12 15 11 8 2 2 0 0 2.30 3.00 3.40 2.15 3.10 3.40 2.10 3.10 3.30 2.20 3.00 3.20 2.30 3.00 3.40 2.40 3.10 3.40
2012 France 06/08/2011 Caen Valenciennes 1 0 H 1 0 H 11 11 3 6 12 11 3 11 2 1 0 0 2.30 3.00 3.40 2.25 3.00 3.30 2.10 3.00 3.40 2.20 3.00 3.20 2.38 3.00 3.20 2.30 3.20 3.60
2012 France 06/08/2011 Marseille Sochaux 2 2 D 1 0 H 27 8 8 3 15 13 4 5 1 3 0 0 1.53 3.80 6.75 1.50 3.90 6.25 1.45 3.90 6.50 1.57 3.50 5.50 1.57 4.00 5.50 1.57 4.00 7.00
2012 France 06/08/2011 Montpellier Auxerre 3 1 H 1 1 D 13 18 4 8 16 22 4 5 0 1 0 0 2.10 3.10 3.80 2.10 3.00 3.70 2.25 3.00 3.05 2.10 3.00 3.40 2.25 3.10 3
@peterbsmyth
peterbsmyth / README.md
Created August 29, 2015 19:41
demoing building blocks

hello markdown

@peterbsmyth
peterbsmyth / README.md
Created August 29, 2015 20:08
GitHub Commit Calendar Clone using D3
@peterbsmyth
peterbsmyth / scopeChain.js
Created September 25, 2015 19:56
Scope Chain Example.
function b(){
console.log(myVar);
}
function a(){
var myVar = 2;
console.log(myVar);
}
var myVar = 1;
@peterbsmyth
peterbsmyth / let.js
Created September 25, 2015 20:08
let in ES6
if (a < b){
let c = true;
}
// ES6 introduces block scoping with let, which means that in the example above c is only
// available in the if statement vs the example below
if (a < b){
@peterbsmyth
peterbsmyth / scopeChainNoAnswer.js
Last active September 27, 2015 17:10
Scope Chain
function b(){
console.log(myVar);
}
function a(){
var myVar = 2;
console.log(myVar);
b();
}
const let reducer = (state={}, action) => {
switch(action.type) {
case RELEVANT_REQUEST:
let nextState;
if (!state[action.day]) {
nextState = Object.assign({}, state, { [action.day]: {} });
}
// Do stuff here
@peterbsmyth
peterbsmyth / README.md
Last active July 11, 2016 16:06
StartFast Code: Task 1

Task #1

-Change the rectangle's color to red
-Change the width and height of the rect to 75 and 150

Notice:

This example uses D3 version 4.1.1

fetch("https://fcctop100.herokuapp.com/api/fccusers/top/recent")
.then(response => {
return response.json().then(json => ({ json, response }))
}).then(({ json, response }) => {
if (!response.ok) {
return Promise.reject(json);
}
// Do Stuff with JSON HERE
// for example...