Skip to content

Instantly share code, notes, and snippets.

View tylor's full-sized avatar

Tylor Sherman tylor

View GitHub Profile
@tylor
tylor / tweet-counts.js
Created December 16, 2012 23:07
Scan your Twitter archive to get a basic count of the people you've talked to and the words that you've used.
/*
* Scan your official Twitter archive to get a basic count of the
* people you've talked to and the words that you've used.
*
* $ node tweet-counts.js ~/path/to/tweets-archive/
*
*/
var fs = require('fs');
var base = process.argv[2].replace(/\/$/, ''); // Strip trailing slash.
var Grailbird = { data: {} }; // The Twitter archive uses this.
@tylor
tylor / Procfile
Created December 7, 2012 20:29
Quick node.js HTTP proxy on Heroku
web: node index.js
@tylor
tylor / tracecircle.js
Created November 13, 2012 07:12
Generate CSS3 transform animation that traces a circle
#!/usr/bin/env node
/**
* Generate CSS3 transform animation that traces a circle.
*
* $ node tracecircle.js animationName vendorPrefix percentStep radiusPixels
*
* For example:
*
* $ node tracecircle.js floating -webkit- 10 20
@tylor
tylor / pg-aws-backups.md
Created November 7, 2012 22:55
Weekly backups of PostgreSQL database to Amazon S3

Weekly backups of PostgreSQL database to Amazon S3

  1. I did this as root: $ sudo su, although it may not be necessary.
  2. Download AWS command line tools: $ curl https://raw.github.com/timkay/aws/master/aws -o aws
  3. Install:
    • Automatically: $ perl --install aws
    • Manually: $ mv aws /usr/local/bin/ && chmod +x /usr/local/bin/aws
@tylor
tylor / allcaps.html
Created October 22, 2012 22:48
Does this hurt?
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>
@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'});}})();
@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 / 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 / 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: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