Skip to content

Instantly share code, notes, and snippets.

@bsmithgall
bsmithgall / omb.html
Created February 13, 2015 16:38
OMB Site HTML
<h4>
REQUESTS FOR QUOTE &amp; LETTER OF INTENT:
</h4>
<ul>
<li>
<a href="http://apps.pittsburghpa.gov/omb/RFQ-LED_Streetlights.pdf">
Streelight LED Upgrade
</a>
<ul>
<li>
@bsmithgall
bsmithgall / title-case.js
Created December 3, 2014 16:01
Title case angular filter
app.filter('titlecase', function () {
return function (input) {
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
// cast the input to lower case to deal with weird all caps issue
input = input.toLowerCase();
return input.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function(match, index, title){
if (index > 0 && index + match.length !== title.length &&
match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
@bsmithgall
bsmithgall / .emacs
Last active August 29, 2015 14:08
emacs/tmux dotfiles for barebones setup
;; Turn off mouse interface early in startup to avoid display
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
;; Handle backups
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
@bsmithgall
bsmithgall / timer.py
Created October 22, 2014 20:50
Time it for eva
# Big thanks to @deacondesperado
class Timer():
def __enter__(self):
self.start = time.clock()
return self
def __exit__(self, *args):
self.end = time.clock()
self.interval = self.end - self.start
@bsmithgall
bsmithgall / index.html
Last active August 29, 2015 14:07
Small Multiples - MultiLine
<!DOCTYPE html>
<html>
<head>
<style>
.chart {
float: left;
padding-right: 5px;
padding-bottom: 5px;
padding-top: 0;
padding-left: 0;
@bsmithgall
bsmithgall / wavepot.js
Created September 18, 2014 03:55
Wavepot (wavepot.com) WIP
var bpm = 240; // beats per minute
var spb = 60/bpm; // seconds per beat
// gets note `n` frequency of `octave`
function note(n, octave){
n += 2;
return Math.pow(2, (n - 33 + (12 * (octave || 0))) / 12) * 440;
}
// random noise
class PaperTowel:
def __init__(self, input='paper towel'):
if isinstance(input, str):
self.output = sum([ord(i) for i in input])
elif isinstance(input, int):
self.output = input
else:
raise Exception("that's not right!")
print type(PaperTowel().output)
@bsmithgall
bsmithgall / lobsta.csv
Created July 6, 2014 22:13
Maine Lobster Sales, not in PDF
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 13 columns, instead of 7. in line 8.
YEAR,SPECIES,METRIC TONS,POUNDS,POUNDS (millions),VALUE,VALUE (millions),PRICE/LB,VALUE OF ONE 2014 DOLLAR (bls),PRICE (adj.),NUMBER OF LICENSE HOLDERS ,NUMBER OF TRAPS - MILLIONS,WATER TEMP AT BOOTHBAY HARBOR
1939,"LOBSTER, AMERICAN","3,005","6,624,823",6.6248,"$1,000,000.00",1,0.15,17.12,$2.57,"3,722",0.26,6.4
1940,"LOBSTER, AMERICAN","3,468","7,644,735",7.6447,"$1,300,000.00",1.3,0.17,16.99,$2.89,"3,717",0.222,7
1941,"LOBSTER, AMERICAN","4,055","8,939,070",8.9391,"$1,600,000.00",1.6,0.18,16.18,$2.91,"3,648",0.194,7.9
1942,"LOBSTER, AMERICAN","3,813","8,405,460",8.4055,"$1,800,000.00",1.8,0.21,14.6,$3.07,"3,511",0.187,8.1
1943,"LOBSTER, AMERICAN","5,203","11,470,410",11.4704,"$2,900,000.00",2.9,0.25,13.75,$3.44,"4,239",0.209,7.4
1944,"LOBSTER, AMERICAN","6,377","14,059,080",14.0591,"$4,000,000.00",4,0.28,13.52,$3.79,"4,926",0.252,8
1945,"LOBSTER, AMERICAN","8,678","19,132,785",19.1328,"$7,700,000.00",7.7,0.4,13.22,$5.29,"6,241",0.378,8.4
1946,"LOBSTER, AMERICAN","8,518","18,779,985",18.78,"$7,200,000.00",7
@bsmithgall
bsmithgall / inflation_calculator.py
Created July 6, 2014 21:55
Value of a 2014 Dollar over Time
import requests
from bs4 import BeautifulSoup
URL = "http://data.bls.gov/cgi-bin/cpicalc.pl?cost1=1.00&year1={year}&year2=2014"
# input a range of years here. The first valid year is 1913.
year_range = xrange(1939, 2014)
print [BeautifulSoup(requests.get(URL.format(year=i)).text).find('span', {'id': 'answer'}).text for i in year_range]
@bsmithgall
bsmithgall / 201402_citibike_trips_rels.json
Created April 27, 2014 22:31
Citibike Network Visualization Using Trips
This file has been truncated, but you can view the full file.
{"216": [{"station_lon": "-73.993915", "end_station": "442", "station_lat": "40.746647", "start_station": "216", "end_station_name": "W 27 St & 7 Ave", "trips": 1}, {"station_lon": "-73.99595065", "end_station": "406", "station_lat": "40.69512845", "start_station": "216", "end_station_name": "Hicks St & Montague St", "trips": 8}, {"station_lon": "-73.98963911", "end_station": "233", "station_lat": "40.69246277", "start_station": "216", "end_station_name": "Joralemon St & Adams St", "trips": 4}, {"station_lon": "-73.98329859", "end_station": "349", "station_lat": "40.71850211", "start_station": "216", "end_station_name": "Rivington St & Ridge St", "trips": 1}, {"station_lon": "-73.99422366", "end_station": "412", "station_lat": "40.7158155", "start_station": "216", "end_station_name": "Forsyth St & Canal St", "trips": 1}, {"station_lon": "-73.963198", "end_station": "2002", "station_lat": "40.716887", "start_station": "216", "end_station_name": "Wythe Ave & Metropolitan Ave", "trips": 1}, {"station_lon": "-73.