Skip to content

Instantly share code, notes, and snippets.

View brycemcd's full-sized avatar

Bryce McDonnell brycemcd

View GitHub Profile
import au.com.bytecode.opencsv.CSVParser
import org.apache.spark.rdd.RDD
val taxis = sc.textFile("/media/brycemcd/filestore/third_party_data/taxi/trip_fare_1.csv")
taxis.cache()
case class Trip(medallion: String,
hack_license: String,
vendor_id: String,
@brycemcd
brycemcd / weather_comparison.r
Created July 21, 2015 01:59
Comparing weather in Portland Oregon with New York City
library('dplyr')
library('tidyr')
library('ggplot2')
temperature_data <- function(dataset, stationName) {
dataset %>%
filter(STATION_NAME == stationName) %>%
mutate(dailyrange = (TMAXF-TMINF)) %>%
select(DATE, TMAXF, TMINF, dailyrange)
}
@brycemcd
brycemcd / user_retention_curve.R
Last active September 21, 2016 12:13
Automatically take a waterfall graph in Mixpanel and create a user retention curve
# Plots a graph of retention after exporting data from Mixpanel's retention
# feature. See Thoughtbot blog: https://robots.thoughtbot.com/create-a-retention-curve-with-mixpanel-and-google-sheets
# and my blog: http://www.brycemcdonnell.com/plotting-user-retention-curves-in-R/
library(lubridate)
library(tidyr)
library(dplyr)
library(ggplot2)
##
@brycemcd
brycemcd / .tmux.conf
Last active August 29, 2015 14:17
My dotfiles
unbind C-b
unbind l
set -g prefix C-e
bind C-e send-prefix
set -g default-terminal "screen-256color"
@brycemcd
brycemcd / explain.md
Last active January 30, 2016 02:27
Using Padrino, database not clearing after each example

I was having a rough time making the test database use transactions when trying out Padrino recently. I added this line to my gemspec:

# Gemfile

group :test do
 # ... some gems
 gem 'database_cleaner'
 # ... some other gems
end
@brycemcd
brycemcd / git-in-status-line.vim
Created July 15, 2014 14:25
Adds # of lines changed to vim statusline
" NOTE: currently appends a "^@" to the end of the line and I haven't
" taken the time to get rid of that
function! LinesChanged()
let dif=system('git diff --stat -- '. bufname('%') .'| cut -d"|" -f2 | head -n 1')
return dif
endfunction
" statusbar:
set statusline= " clear the line
@brycemcd
brycemcd / rack_cache_meta_disk.rb
Created February 27, 2014 18:47
Read values from Rack::Cache's meta Disk store
# For future Bryce to Google and find...
# in irb session:
f = File.read("meta/7e/13c49c3d286767984ee2d801df056cb879d2a2"); nil # nil is here so it doesn't barf the contents of the file into the console
headers = Marhsal.load(f)
headers = headers[0]
@brycemcd
brycemcd / a_v_nerd.js
Created February 19, 2014 16:50
Playing around with the HTML5 audio/video controls
// Load up an mp3 in a FF address bar.
// in the browser. Don't let it autoplay.
// in FF, the mp3 loads in a video player. Create a var to reference the video player:
var v = document.getElementsByTagName("video")[0];
// set the playhead at 0 and then play:
v.currentTime = 0;
v.pause();
@brycemcd
brycemcd / headlines.rb
Created January 8, 2014 05:04
quick Nokogiri script to pull headlines out of news articles
require 'rubygems'
require 'nokogiri'
require 'open-uri'
# Takes a URL for a news site (like Huffpo or Yahoo) as input and outputs the Headline
url = ARGV[0]
resource = NokoGiri::XML(open(url))
@brycemcd
brycemcd / shared_vim_confs.md
Created October 26, 2013 15:26
HowTo: share vim confs (using janus) between two computers using bittorrent sync

How To Share Vim Configuration Between Two Computers Using Bittorrent Sync

Explanation of Setup

I have a shared directory that I keep in sync between my desktop at home and my laptop at work. The directory is ~/.shared_conf. I keep them in sync using (BitTorrentSync)[http://labs.bittorrent.com/experiments/sync.html] . It works great on a LAN and over a WAN.

I use (The Janus flavor of vim configs)[https://github.com/carlhuda/janus].

Keeping my vim files (and janus files) in sync between the two computers keeps my vim experience consistent between my machines.