Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / .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 / 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 / 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 / parse_blotter.py
Last active August 29, 2015 14:15
Parse Police Blotter with wextractor
import requests
import datetime
import time
import tempfile
from wextractor.extractors import CsvExtractor
upload_url = 'http://opendata.ucsur.pitt.edu/data/api/action/datastore_upsert?resource_id=eaa91ff8-6d63-4750-810a-53957a344346'
resource_id = 'eaa91ff8-6d63-4750-810a-53957a344346'
@bsmithgall
bsmithgall / dogs.json
Last active August 29, 2015 14:18
Sublime Keyboard Shortcuts
// COMMAND + CONTROL + G --> select all matches on a page
// COMMAND + CLICK --> add a new cursor
// COMMAND + D --> select the next match
// COMMAND + CONTROL + UP ARROW --> move the highlighted line up
// COMMAND + CONTROL + DOWN ARROW --> move the highlighted line down
// COMMAND + SHIFT + L (over highlighted lines) --> CURSOR AT THE END OF EACH LINE
// COMMAND + SHIFT + P --> Opens command window for sublime
// CONTROL + N --> Down one line
// CONTROL + P --> Up one line
// CONTROL + F --> Forward one character
@bsmithgall
bsmithgall / cruise.js
Last active August 29, 2015 14:18
fun with p5
var x = 0, backwards = false, s = 800, y = 0, up=true,
r=0, g=0, b=0, circleWidth = 100, mavericks=[],
maxR = false, maxG = false, maxB = false, fft, song, img;
function preload() {
song = loadSound('danger-zone.mp3');
img = loadImage('maverick.png');
}
function setup() {
@bsmithgall
bsmithgall / open-vis.md
Last active August 29, 2015 14:19
Open Vis Notes
@bsmithgall
bsmithgall / base_test.py
Created April 27, 2015 22:42
Testing w/Mocks, Persona
from unittest import TestCase
from mock import Mock, patch
class BaseTestCase(TestCase)
@patch('urllib2.urlopen')
def login_user(self, user, urlopen):
_email = user.email if user else '[email protected]'
mock_open = Mock()
mock_open.read.side_effect = ['{"status": "okay", "email": "' + _email + '"}']
urlopen.return_value = mock_open