Skip to content

Instantly share code, notes, and snippets.

View ajschumacher's full-sized avatar

Aaron Schumacher ajschumacher

View GitHub Profile
@ajschumacher
ajschumacher / build_logins.sh
Last active March 6, 2018 19:29 — forked from JoshData/build_logins.sh
script for making users for multi-user RStudio
#!/bin/bash
# Start an AWS instance with one of the AMIs provided by:
# http://www.louisaslett.com/RStudio_AMI/
#
# Get this script and make executable.
# wget THE_RAW_URL
# chmod +x build_logins.sh
#
# Then use this script to create many logins on the system.
@ajschumacher
ajschumacher / scoring.R
Created August 17, 2014 17:46
code for a blog post on Wilson scoring vs. Laplace smoothing
par(pty='s')
par(mfrow=c(1, 2))
ci_lower_bound <- function(pos, n, confidence) {
if (n == 0) return(0)
z = qnorm(1 - (1 - confidence) / 2)
p = pos / n
(p + z^2 / (2*n) - z * sqrt((p * (1-p) + z^2 / (4*n)) / n )) /
(1 + z^2 / n)
longest.ordered <- function(original) {
results <- list()
for (item in original) {
static_results <- results
for (stem in static_results) {
if (stem[length(stem)] <= item) {
results[[length(results)+1]] <- c(stem, item)
}
}
results[[length(results)+1]] <- item
# oh my quiz
What the what?
: Option!
: Correct option! :
@ajschumacher
ajschumacher / mapping.R
Last active August 29, 2015 13:58
figuring out state key names, or other problem
test <- data.frame(state=c("Florida", "Virginia", "Texas", "California",
"Georgia", "North Carolina", "New York",
"Missouri", "Illinois", "Maryland", "Pennsylvania",
"Tennessee", "Colorado", "Washington", "Arizona",
"Ohio", "Wisconsin", "District of Columbia",
"Michigan", "New Jersey", "Utah", "Louisiana",
"Minnesota", "Alabama", "Kansas", "Massachusetts",
"Indiana", "South Carolina", "Arkansas", "Oregon",
"Nevada", "Kentucky", "Nebraska", "(not set)",
"Connecticut", "New Mexico", "Oklahoma",
@ajschumacher
ajschumacher / wrapup4.md
Created December 20, 2013 02:18
DC Hack and Tell Round 4: The Christmas Invasian
@ajschumacher
ajschumacher / wrapup3.md
Last active December 29, 2015 12:19
DC Hack and Tell Round 3: Hack... to the Future!
@ajschumacher
ajschumacher / logo.R
Created September 5, 2013 01:32
hacky stat prog DC logo in R
set.seed(54)
n <- rnorm(3000,0.5,0.1)
par(mar=c(1,1,3,1))
hist(c(runif(10000),runif(1900,0.35,0.65),n[abs(n-0.5)<0.15]),
xlim=c(0,1),ylim=c(0,600),breaks=51,ylab="",#main="",
main="Statistical Programming DC",col="#C9242D",
axes=F, cex.main=2)
@ajschumacher
ajschumacher / movie_reviews.py
Created July 16, 2013 02:54
another solution to this munging problem
movie_reviews = dict()
for line in open('movies.txt.small'):
pieces = line.split(':')
if len(pieces) > 1:
key = pieces[0]
value = ':'.join(pieces[1:]).strip()
if key == 'product/productId':
id = value
if key == 'review/text':
movie_reviews.setdefault(id, []).append(value)
@ajschumacher
ajschumacher / README.md
Last active December 16, 2015 23:08
intense brainstorming

oh nothing, nothing...