Skip to content

Instantly share code, notes, and snippets.

View stormpython's full-sized avatar

Shelby Sturgis stormpython

  • Netflix
  • San Francisco, CA
View GitHub Profile
@stormpython
stormpython / timechart.js
Created April 2, 2014 14:53
Link Function
define(function (require) {
var _ = require('lodash');
var $ = require('jquery');
var k4 = require('K4D3');
var app = require('modules').get('app/discover');
app.directive('discoverTimechart', function ($compile) {
return {
restrict: 'E',
$scope.data = {
"rows": [
{
"columns": [
{
"label": "200 requests",
"xAxisLabel": "Date",
"yAxisLabel": "Average Request Size in Bytes",
"layers": [
{
@stormpython
stormpython / flaskapp
Created April 10, 2014 13:51
nginx conf file
server {
listen 80;
root /usr/ubuntu/insighfl;
index index.html index.htm;
server_name "";
location / {
proxy_pass http://127.0.0.1:5000;
define(function(require) {
'use strict';
var _ = require('lib/lodash/dist/lodash');
/* Returns the indexed position of a value in an array. */
function isValInArr(val, arr) {
for (var i = 0; i < arr.length; i++) {
// if (!arr[i]) { arr.splice(i, 1); return 0; }
if (arr[i].x === val) { return i; }
@stormpython
stormpython / brush.js
Last active August 29, 2015 14:01
Brush code for histogram
brush = d3.svg.brush()
.x(xScale)
.on('brushend', brushend);
if (dispatch.on('brush')) {
svg.append('g')
.attr('class', 'brush')
.call(brush)
.selectAll('rect')
.attr('height', height);
@stormpython
stormpython / schema.sql
Created June 5, 2014 08:14
Example MySQL schema
-- Example table schema
-- To import your schemas into your database, run:
-- `mysql -u username -p database < schema.sql`
-- where username is your MySQL username
-- Load data into table
-- LOAD DATA LOCAL INFILE 'country.csv' INTO TABLE world_index
-- FIELDS TERMINATED BY ','
-- ENCLOSED BY ''
-- LINES TERMINATED BY '\n'

InsightFL Presentation @ Insight Data Science

Snippets of files used to create a data table and bubble chart.

// Pulling values recursively from Pie Chart Data
function getSize (obj) {
return obj.size;
}
function isZero (d) {
return d.size === 0;
}
@stormpython
stormpython / grid_layout.js
Created February 13, 2015 18:34
Grid Layout
// D3 code
var $el = $('.visualize-chart')[0];
var data = {
type: 'chart',
series: [{}, {}, {}]
};
var selection = d3.select($el).datum(data).call(split);
function split (selection) {
selection.each(function (data) {
@stormpython
stormpython / country.csv
Last active August 29, 2015 14:21
Insight Data Visualization Workshop
country median_age gdp edu_index
Afghanistan 18 18949 0.354
Albania 30.2 13000 0.886
Algeria 27.1 198735 0.748
Andorra 39.9 3577 0.878
Antigua and Barbuda 30 1118 0.945
Argentina 30.3 448165 0.946
Australia 37.5 1515468 0.993
Austria 42.6 418031 0.962
Azerbaijan 28.5 63404 0.881