Skip to content

Instantly share code, notes, and snippets.

View tylor's full-sized avatar

Tylor Sherman tylor

View GitHub Profile
@tylor
tylor / package.json
Created January 25, 2012 03:41
Read all CSVs in a directory and do something with them
{
"author": "tylor",
"name": "csv_street_trees",
"version": "0.0.0",
"repository": {
"url": ""
},
"main": "trees.js",
"engines": {
"node": "~v0.4.9"
@tylor
tylor / gist:1719855
Created February 1, 2012 22:24
Facebook IPO filing word frequency analysis
Quick and dirty word frequency analysis of the Facebook IPO filing document found here: http://www.sec.gov/Archives/edgar/data/1326801/000119312512034517/d287954ds1.htm
Using command from: https://josephhall.org/nqb2/index.php/word_frequency
$ tr '[A-Z]' '[a-z]' < facebook_ipo.txt | tr -cd '[A-Za-z0-9_ \012]' | tr -s '[ ]' '\012' | sort | uniq -c | sort -nr
Or copy passage to clipboard and paste to command line:
$ pbpaste | tr '[A-Z]' '[a-z]' | tr -cd '[A-Za-z0-9_ \012]' | tr -s '[ ]' '\012' | sort | uniq -c | sort -nr
@tylor
tylor / index.js
Created March 7, 2012 23:03
JSON to CSV
var fs = require('fs');
var csv = require('csv');
var data = fs.readFileSync('all_reports.json', 'utf8');
var lines = data.split("\n");
var all = [];
for (var i = 0; i < lines.length; i++) {
console.log(i);
var items = JSON.parse(lines[i]).items;
@tylor
tylor / gist:2792879
Created May 26, 2012 08:14
Carto style for parking meters in Vancouver
Map {
background-color: #b8dee6;
}
#countries {
::outline {
line-color: #85c5d3;
line-width: 2;
line-join: round;
}
@tylor
tylor / gist:2892478
Created June 7, 2012 23:52
Quick CSS fix for echomemoirs.com
/* Full length pages, remove fancy scroll bar, and add clearfix */
#Faux:after,
.Faux:after,
#FauxInside:after,
.FauxInside:after,
#Main:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
@tylor
tylor / gist:3013990
Created June 28, 2012 21:23
HOT 97 weekly songs
In a week of broadcast HOT 97 played 1165 tracks, which breaks down to 86 unique songs.
The top 10 songs make up 55% of plays and the top 20 songs make up nearly 74% of plays.
86 "MERCY" - KANYE WEST FT BIG SEAN, PUSTA T & 2CHAINZ
86 "LEMME SEE" - USHER FEAT. RICK ROSS
80 "THE MOTTO" - DRAKE
78 "UP REMIX" - LOVERANCE FT 50 CENT, YOUNG JEEZY & T.I.
72 "COLD (SHORT)" - KANYE WEST FT DJ KHALED
56 "HANDS ON THE WHEEL" - SCHOOL BOY Q FT ASAP ROCKY
47 "LEAVE YOU ALONE" - YOUNG JEEZY
@tylor
tylor / rate-limit.c
Created July 9, 2012 23:14
Simply code to rate limit your stdout.
/*
* Simply code to rate limit your stdout.
*
* Compile:
* - $ gcc limit.c
* Fun uses:
* - $ find ~/Sites/thisisourstop/ -name "*.js" -exec cat {} \; | ./a.out 1000
* - $ ./a.out < /dev/random
*/
#include <stdio.h>
@tylor
tylor / gist:3724845
Created September 14, 2012 21:09
DriveBC incident data 2006-2011
Some basic queries of the DriveBC incident data 2006-2011.
Total incidents: 817479
Number of incidents by region:
Rocky Mountain District 149174
West Kootenay District 133435
Thompson Nicola District 101701
Cariboo District 92216
@tylor
tylor / index.js
Created September 14, 2012 21:48
Quick and dirty CSV to Postgres import for DriveBC
var csv = require('csv');
var pg = require('pg');
var connectionString = 'postgres://tylor@localhost/drivebc';
var client = new pg.Client(connectionString);
client.connect();
client.query("DROP TABLE incidents");
client.query("CREATE TABLE incidents(import_id serial primary key, \"id\" varchar(255), cause varchar(255), district varchar(255), state varchar(255), severity varchar(255), localupdatetime varchar(255), advisorymessage text, isbidirectional varchar(255), trafficpattern varchar(255), head_latitude varchar(255), head_longitude varchar(255), tail_latitude varchar(255), tail_longitude varchar(255), route varchar(255), type varchar(16))");
@tylor
tylor / papyrus.js
Created September 19, 2012 21:52
Bookmarklet to change font to Papyrus
javascript:(function() {if(typeof jQuery=='undefined'){var j=document.createElement('script');j.type='text/javascript';j.onload=papyrus;j.src='http://is.gd/uDgzgG';document.body.appendChild(j);}else{papyrus();}function papyrus(){$('*').css({'font-family':'Papyrus'});}})();