Skip to content

Instantly share code, notes, and snippets.

View carbocation's full-sized avatar

James Pirruccello carbocation

View GitHub Profile
@carbocation
carbocation / loghistplot.R
Last active February 14, 2018 02:22 — forked from sckott/loghistplot.R
Plot logistic regression with bar plots for distribution of 0 and 1 values on top and bottom x-axes.
# Define the function
loghistplot <- function(data) {
require(ggplot2); require(gridExtra) # load packages
names(data) <- c('x','y') # rename columns
# get min and max axis values
min_x <- min(data$x)
max_x <- max(data$x)
2006-1 8.040729483282673
2006-2 8.00303951367781
2006-3 8.016413373860182
2006-4 8.010334346504559
2006-5 8.012765957446808
2006-6 7.9969604863221875
2006-7 7.999392097264437
2006-8 7.982370820668692
2006-9 8.0370820668693
2006-10 8.038297872340424
@carbocation
carbocation / gist:17af347fd38bb302dafc21f77832e4b5
Last active October 22, 2017 16:50 — forked from bigsnarfdude/gist:95c19664f5f8aa5b8b403308c5d42b23
training tensorflow and saving my MNIST model
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
#import data
mnist = input_data.read_data_sets("data/", one_hot=True)
sess = tf.InteractiveSession()
# Create the model
x = tf.placeholder(tf.float32, [None, 784])
@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