Skip to content

Instantly share code, notes, and snippets.

View mgahan's full-sized avatar

Mike Gahan mgahan

View GitHub Profile
# Server config
server {
listen 80 default_server;
listen [::]80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
@mgahan
mgahan / MapShaperSimplify.R
Created May 1, 2018 19:36
Mapshaper Example
#mapshaper tl_2013_31_cousub.shp -simplify weighted 0.02% -o simplified.shp
library(rgdal)
library(sp)
before <- readOGR("tl_2013_31_cousub.shp")
after <- readOGR("simplified.shp")
plot(before)
plot(after)
library(data.table)
check <- fread("https://storage.googleapis.com/playground-mike/weather/1315015.csv")
check[, .N, keyby=.(NAME)]
check <- check[, .(NAME, DATE,TMAX,TMIN)]
check <- na.omit(check, invert=FALSE)
check[, DATE := as.Date(DATE)]
check[, YEAR := year(DATE)]
check[, MONTH := month(DATE)]
@mgahan
mgahan / BowlConferenceStandings.R
Created December 31, 2017 05:41
Why Bowl Conference Standings are stupid?
# Bring in libraries
library(data.table)
set.seed(1L)
# Data
bowlgames <- structure(list(TEAM1 = c("Michigan", "Notre Dame", "Louisville",
"Memphis", "Wake Forest", "NC State", "Kentucky", "New Mexico State",
"Virginia", "Virginia Tech", "Stanford", "Michigan State", "Florida State",
"Iowa", "Purdue", "Texas", "West Virginia", "Duke", "Kansas State",
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<div>
@mgahan
mgahan / OpenVpn.sh
Created November 10, 2017 22:51
OpenVPN Creation with Google Cloud
# Create Ubuntu 16.04 instance to host openvpn
gcloud compute instances create openvpn-pritunl \
--image-family ubuntu-1604-lts --image-project ubuntu-os-cloud \
--zone us-west1-a \
--network default \
--tags https-server,http-server \
--address vpn-static \
--service-account [email protected] \
@mgahan
mgahan / GibbsSamplierExample.R
Created November 2, 2017 22:35
Example of a Cauchy Gibbs Sampler
library(MCMCpack)
rm(list=ls())
set.seed(83247279)
reps=50000
# draw data from the cauchy distribution
x.dat <- rcauchy(100, location=2, scale=0.8)
######### now recover the location and the scale