Skip to content

Instantly share code, notes, and snippets.

View carbocation's full-sized avatar

James Pirruccello carbocation

View GitHub Profile
@carbocation
carbocation / zerocor.R
Last active September 10, 2017 17:31
Monte Carlo simulation to compare two vectors, one of which has no variance
library(MonteCarlo)
df <- data.frame(x=c(2.2, 2.2, 2.2, 2.2, 2.2), y=c(2.2, 1.2, 1.3, 2.4, 2.6))
df$trend <- seq(1,length(df$x))
pv <- function(noparams) {
return(list("p.value"=cor(jitter(df$x), df$y)))
}
param_list <- list("noparams"=c(0))
@carbocation
carbocation / upgrade-postgres-9.5-to-9.6.md
Last active May 30, 2017 00:36 — forked from delameko/upgrade-postgres-9.5-to-9.6.md
Upgrading PostgreSQL from 9.5 to 9.6 on Ubuntu 16.04

TL;DR: This script upgrades postgres 9.5 to 9.6 on a server that uses a custom data directory.

sudo echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
  sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6 postgresql-client-9.6 postgresql-contrib-9.6
KCNB1
GNAS
PRPF4B
INTS6
CACNA1C
HNRNPA0
DHX8
UBTF
SMARCA4
ZNF768
@carbocation
carbocation / tumblr-gist.js
Created May 5, 2017 19:54 — forked from slezica/tumblr-gist.js
tumblr gist embedder
var real_docwrite = document.write,
body = $('body');
(function insertGists(a_tags) {
if (a_tags.length > 0) {
a_tag = a_tags.shift()
document.write = function(stylesheet) {
$('head').append(stylesheet);
@carbocation
carbocation / string_vs_int_test.go
Last active September 4, 2016 02:51
Demonstrates that the string representation of an int64 requires twice the memory
package typesizes
import (
"math"
"strconv"
"testing"
)
var N int = 1e7
var stringSize int = 1 + int(math.Log10(float64(N)))
@carbocation
carbocation / Router.swift
Last active September 16, 2015 00:01
Uploading a file with SWIFT via POST multipart/form-data (PHP)
import Foundation
import Alamofire
public enum Router:URLRequestConvertible {
public static let baseUrlString:String = "http://testapi.example.com"
case Upload(fieldName: String, fileName: String, mimeType: String, fileContents: NSData, boundaryConstant:String);
var method: Alamofire.Method {
switch self {
case Upload:
package poison
import (
"database/sql"
"reflect"
"github.com/gorilla/schema"
)
// Convertors for sql.Null* types so that they can be
@carbocation
carbocation / tree_test.go
Last active December 16, 2015 00:49
This is a test of the binary tree / recursive template parsing example given by Rob Pike in the go-nuts mailing list. It has been updated to be compatible with go 1.0.3+, including 1.1beta2. His post can be found here: https://groups.google.com/d/msg/golang-nuts/wk5IyGzHQf8/BeWnz82qEEwJ
/*
This is a test of the binary tree / recursive template parsing example given by Rob Pike
in the go-nuts mailing list. It has been updated to be compatible with go 1.0.3+, including
1.1beta2. His post can be found here: https://groups.google.com/d/msg/golang-nuts/wk5IyGzHQf8/BeWnz82qEEwJ
Run this with `go test tree_test.go`, not with `go run`.
*/
package main
import (
@carbocation
carbocation / gist:5278173
Last active February 14, 2016 18:40
On OS X, use fswatch to automatically recompile your golang project whenever you change a file in the directory.
#!/bin/bash
# This script keeps watch on the current project and compiles it continuously as you change files.
# If there are multiple projects with the same final directory name (e.g., /proj/rad and /lib/monster/rad),
# this will kill any other similarly-named running projects' binaries, potentially leading to havoc.
# To run, install fswatch, drop this file into your project directory, make it executable, and run:
# /usr/local/bin/fswatch ./ ./continuous-compile.sh
echo "Re-compiling"
@carbocation
carbocation / nyc_teachers.R
Created January 28, 2013 04:15
An examination of NYC teacher rating data
path <- "/Users/jpirruccello/Downloads"
library(ggplot2)
library(mboost)
#Load the data
y09 <- read.csv(paste(path,"TDI_20082009_FOIL_Press_JP.txt",sep="/"),sep="\t")
y10 <- read.csv(paste(path,"TDI_20092010_FOIL_Press_JP.txt",sep="/"),sep="\t")
#Identify teachers by the following, and make a merged dataframe based on the uniqueness thereof: