Skip to content

Instantly share code, notes, and snippets.

View tomschenkjr's full-sized avatar

Tom Schenk Jr tomschenkjr

View GitHub Profile
@tomschenkjr
tomschenkjr / Julia Workshop notes 20141115.jl
Created November 18, 2014 00:39
Notes from Julia Workshop: From Installed to Productive
# Notes from Julia Workshop: From Installed to Productive
# 2014-11-15
# http://www.meetup.com/JuliaChicago/events/216950712/
println("hello world") # => hello world
x = 5
## IF statements
@tomschenkjr
tomschenkjr / sublime-path
Last active October 5, 2015 18:58
Setting PATH for Sublime Text 2
{
"default_extend_env":{"PATH":"{PATH};C:\\Users\\user_name\\Documents\\R\\R-2.14.1\\bin\\x64"}
}
@tomschenkjr
tomschenkjr / Remove-period-as-R-separator
Last active October 6, 2015 20:38
Remove period (.) as a separator in R script.
// Characters that are considered to separate words – does not include periods.
// Place comma at the end of the line if there are multiple keybindings.
{"word_separators": "/\\()\"‘-:,;~!@#$%^&*|+=[]{}`~?"}
@tomschenkjr
tomschenkjr / getuser.php
Created September 5, 2012 14:32
Create a dropdown box to query data and display in table on HTML page
<?php
$q=$_GET['q'];
$con = mysql_connect('mysql.tomschenkjr.net', 'tsjr_visitor', 'tsjr_visitor_password');
if(!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tsjr_sandy", $con);
@tomschenkjr
tomschenkjr / ggplot2-tutorial-2.R
Created October 29, 2012 18:37
Chicago Data Visualization ggplot2 Tutorial 2 Script
# LOAD UP GGPLOT2
library(ggplot2)
# PROPER TIME SERIES DATA
str(economics) # Explore the economics data set that comes with ggplot2.
# PLOT THE RELATIONSHIP OF UNEMPLOYMENT AND TIME
p <- ggplot(economics, aes(x = date, y = unemploy))
p + geom_line()
@tomschenkjr
tomschenkjr / ggplot2-tutorial-3.R
Created November 12, 2012 20:45
Chicago Data visualization ggplot2 Tutorial 3 Script
# Let's customize our plot outputs. First, load the library.
library(ggplot2)
# Plot something simple
p <- ggplot(mtcars, aes(x=cyl, y=mpg)) + geom_point(aes(color=qsec, size=wt))
# Change axis
p + scale_y_continuous(limits=c(0,40))
CoefficientPlot <- function(models, alpha = 0.05, modelnames = ""){
# models must be a list()
Multiplier <- qnorm(1 - alpha / 2)
CoefficientTables <- lapply(models, function(x){summary(x)$coef})
TableRows <- unlist(lapply(CoefficientTables, nrow))
if(modelnames[1] == ""){
ModelNameLabels <- rep(paste("Model", 1:length(TableRows)), TableRows)
} else {
@tomschenkjr
tomschenkjr / chicago-cla-v1
Last active December 18, 2015 11:39
Draft of Chicago's Contributor Licensing Agreement
City of Chicago
Individual Contributor License Agreement ("Agreement")
======================================================
Thank you for your interest in [Project Name] by the City of Chicago (the "City"),
a municipal corporation and home rule unit of local government existing under the
Constitution of the State of Illinois. In order to clarify the intellectual property
license granted with Contributions from any person or entity, the City must have a
Contributor License Agreement ("CLA") on file that has been signed by each Contributor,
indicating agreement to the license terms below. This license is for your protection
@tomschenkjr
tomschenkjr / CPS_HS_Progress_Report_2014_Transformations.txt
Created December 18, 2013 19:57
This gist contains the original pre-converted data file for CPS High School Progress Report 2013-2014. The second file is a JSON layout that contains the transformations applied within OpenRefine to transform the data file. The file transforms the original file to the published copy at https://data.cityofchicago.org/id/2m8w-izji. These files acc…
[
{
"op": "core/text-transform",
"description": "Text transform on cells in column Phone Number using expression grel:value.replace(\" -\",\"\")",
"engineConfig": {
"facets": [],
"mode": "row-based"
},
"columnName": "Phone Number",
"expression": "grel:value.replace(\" -\",\"\")",
@tomschenkjr
tomschenkjr / geocode.R
Created January 10, 2016 23:10
A note on how to geocode using R, since I always forget
# A note on how to geocode using R, since I always forget
library(tigris) # also loads 'sp'
library(RSocrata)
# Obtain data
d <- read.socrata("https://data.cityofchicago.org/Education/Connect-Chicago-Locations/bmus-hp7e")
ccgeo <- tracts(state = '17', county = c('031'), cb = T) ## cb=T means smaller file
# Data organization