This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#that title doesn't get me on a list... | |
use Parallel::ForkManager; | |
use Data::Dumper; | |
my @sleep = ( | |
10, | |
60, | |
60, | |
60, | |
60, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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;\ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
points = spark.textFile(...).map(parsePoint).cache() | |
w = numpy.random.ranf(size = D) # current separating plane | |
for i in range(ITERATIONS): | |
gradient = points.map( | |
lambda p: (1 / (1 + exp(-p.y*(w.dot(p.x)))) - 1) * p.y * p.x | |
).reduce(lambda a, b: a + b) | |
w -= gradient | |
print "Final separating plane: %s" % w |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
use Data::Dumper; | |
my @records = (); | |
my $now = time(); | |
my $weeks = 604800 * 52; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sourceCpp('../src/string_slicer.cpp') | |
sliced_string <- string_slicer(s, cutpoints$start, cutpoints$end) |