Skip to content

Instantly share code, notes, and snippets.

@earino
earino / foo.py
Created February 4, 2014 03:34
Better Logistic Example in Apache Spark
from pyspark.mllib.classification import LogisticRegressionWithSGD
from numpy import array
# Load and parse the data
data = sc.textFile("mllib/data/sample_svm_data.txt")
parsedData = data.map(lambda line: array([float(x) for x in line.split(' ')]))
model = LogisticRegressionWithSGD.train(parsedData)
# Build the model
labelsAndPreds = parsedData.map(lambda point: (int(point.item(0)),
@earino
earino / c_in.js
Created February 19, 2014 17:22
Why is there C in my javascript?!
/* from http://madebyevan.com/webgl-water/water.js
used in the awesome WebGL water demo
http://madebyevan.com/webgl-water/*/
this.dropShader = new GL.Shader(vertexShader, '\
const float PI = 3.141592653589793;\
uniform sampler2D texture;\
uniform vec2 center;\
uniform float radius;\
uniform float strength;\
@earino
earino / modern.pl
Created February 28, 2014 05:47
syntax highlighted version
package LedgerSMB::Currency;
use Moose;
with 'LedgerSMB::PGOSimple::Role', 'LedgerSMB::MooseTypes';
use PGObject::Util::DBMethod;
sub _set_prefix { 'currency__' }
has id => (is => 'rw', isa => 'Int', required => '0');
has symbol => (is => 'ro', isa => 'Str', required => '1');
print("start.207")
for (i in 1:5) {
t <- get(paste0("d", i));
y <- factor(t[,c("start.207")], levels=c("1", "0"))
x <- t[,c("stop.165","stop.166","stop.167","stop.168","stop.169","stop.185",
"stop.186","stop.187","stop.188","stop.189","stop.205","stop.206",
"stop.207","stop.208","stop.209","stop.225","stop.226","stop.227",
"stop.228","stop.229","stop.245","stop.246","stop.247","stop.248","stop.249")]
md <- train(x, y, method="rf", ntree=ntrees, trControl=trainControl(method="cv"))
@earino
earino / kill_children.pl
Created May 23, 2014 01:44
how i just killed the children
#that title doesn't get me on a list...
use Parallel::ForkManager;
use Data::Dumper;
my @sleep = (
10,
60,
60,
60,
60,
@earino
earino / holly_holm_opponents.csv
Created July 11, 2014 00:20
A CSV of Holly Holm's opponents, and the last year they were active according to the fightfinder
fighter wins losses last_year_fought
juliana werner 7 4 2014
angela hayes 6 7 2013
nikki knudsen 2 2 2013
allana jones 2 5 2014
katie merrill 1 1 2013
jan finney 8 10 2011
christina domke 4 2 2011
@earino
earino / joke_map.R
Created August 3, 2014 20:32
joke_map.R
joke_map <- function(states_to_highlight, title="", highlight_colors=c("#aaaaaa", "#ee0000")) {
library(dplyr)
library(ggplot2)
library(RColorBrewer)
library(maps)
highlighting = data.frame(region=tolower(state.name[match(states_to_highlight, state.abb)]),
highlight=TRUE)
d = map_data("state") %>% left_join(highlighting, by="region")
@earino
earino / calling.R
Created August 3, 2014 20:39
calling joke_map
map <- joke_map(states_to_highlight = c("AK", "AZ", "CA", "CT", "DE", "HI", "IA", "MA", "NE", "NH", "NJ", "NY", "NV", "OR", "PA", "RI", "VT", "VA", "WA"), title = "States That Hate Freedom (and wildfires)")
@earino
earino / bluest.R
Created August 3, 2014 20:41
bluest
map <- joke_map(states_to_highlight = c("WY"), title = "Squarest, Bluest State", highlight_colors=c("#aaaaaa", "#0000ee"))
@earino
earino / keybase.md
Created September 22, 2014 17:10
keybase.md

Keybase proof

I hereby claim:

  • I am earino on github.
  • I am earino (https://keybase.io/earino) on keybase.
  • I have a public key whose fingerprint is EC06 4396 DCB2 701F 2747 9DD5 32A3 4E21 1D49 484A

To claim this, I am signing this object: