Skip to content

Instantly share code, notes, and snippets.

View LeeMendelowitz's full-sized avatar

Lee Mendelowitz LeeMendelowitz

View GitHub Profile
@LeeMendelowitz
LeeMendelowitz / README.md
Last active August 29, 2015 14:15
DC Metro Metrics Data Download
@LeeMendelowitz
LeeMendelowitz / error.R
Created July 23, 2014 22:41
Gist demonstrating an R error
# The question: why does make.plot.1 cause an error?
# make.plot.2 and make.plot.3 work ok.
#
# I'm trying to use ggplot to make a scatter plot with
# with size mapped to the "s" variable in the dataframe.
# When I try to draw circles on top of the scatter plot using geom_path, I get
# errors.
# The plot works if I choose to not map size or not to draw the circles.
@LeeMendelowitz
LeeMendelowitz / gist:f6da6480eb87cb55c1ad
Last active August 29, 2015 14:02
Predict.lm not working for matrix data
# Make a dataset where Y is cubic in X, plus noise:
n <- 1000
x <- runif(n)
x <- sort(x)
eps <- rnorm(n)
beta <- c(1, 2, 3)
X <- poly(x, 3, raw = TRUE)
y <- X %*% beta + eps
# Fit the data
@LeeMendelowitz
LeeMendelowitz / wrap_file_function.py
Last active August 29, 2015 14:00
Wrapping a file function
class wrap_file_function(object):
"""
Wrap a function which takes a file or a str as it's first argument.
If a str is provided, replace the first argument of the wrapped function
with a file handle, and close the file afterwards
Example:
@wrap_file_function('w')
def write_hi(f):
@LeeMendelowitz
LeeMendelowitz / index.html
Created April 29, 2014 12:51
D3 Merging Enter Selection with Update Selection
<!DOCTYPE html>
<html>
<head>
<title>Playing with Enter and Update</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
p {
color: black;
}
@LeeMendelowitz
LeeMendelowitz / any_all.ipynb
Last active August 29, 2015 13:55
ipython notebook demonstrating Python generators and the any/all functions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.