Skip to content

Instantly share code, notes, and snippets.

View stevenworthington's full-sized avatar

Steven Worthington stevenworthington

View GitHub Profile
@stevenworthington
stevenworthington / facet_reg.R
Created April 20, 2015 18:40
ggplot regression example using facets
data(mtcars)
library(ggplot2)
plot1 <- ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point() +
geom_smooth(method = "lm") +
facet_wrap(~ cyl) +
theme_bw()
@stevenworthington
stevenworthington / get_lat_lon_exif_pil.py
Created December 12, 2015 02:49 — forked from erans/get_lat_lon_exif_pil.py
Get Latitude and Longitude from EXIF using PIL
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
def get_exif_data(image):
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags"""
exif_data = {}
info = image._getexif()
if info:
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
@stevenworthington
stevenworthington / predict_vs_simulate.R
Created January 5, 2016 20:59
Some plots to illustrate the differences between predict vs simulate in Lme4
library(lme4)
head(sleepstudy)
summary(sleepstudy)
sapply(sleepstudy, class)
# Fit model using the original data:
d <- sleepstudy
d$Subject <- factor(rep(1:18, each=10))
fm1 <- lmer(Reaction ~ Days + (Days|Subject), d)
@stevenworthington
stevenworthington / gist:cd5341455e4309ef204a
Created February 10, 2016 00:53 — forked from crsh/gist:4f9ce67f408611bc3974
Add events with time frame to plot.gantt()
# Function definition
add_event <- function(start, end = NULL, label = NULL, line = 0.5, las = 1, col = scales::alpha("steelblue", 0.5)) {
if(is.null(end)) {
end <- paste(start, "23:59:59")
start <- paste(start, "00:00:00")
}
start <- as.POSIXct(start)
end <- as.POSIXct(end)
@stevenworthington
stevenworthington / python_cheatsheets.txt
Created January 4, 2023 02:07 — forked from simplymanas/python_cheatsheets.txt
Collection of Python cheatsheet
https://docs.python.org/3/reference/index.html
https://docs.python.org/3/library/index.html
https://www.cs.put.poznan.pl/csobaniec/software/python/py-qrc.html
https://perso.limsi.fr/pointal/python:abrege
https://perso.limsi.fr/pointal/python:memento
https://perso.limsi.fr/pointal/_media/python:cours:abregepython.pdf
https://perso.limsi.fr/pointal/_media/python:cours:abregepython-english.pdf
https://perso.limsi.fr/pointal/_media/python:cours:mementopython3.pdf