This file contains 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
bits <- 1:8 | |
n <- 2 ^ bits | |
plot(n ~ bits, type = "b") |
This file contains 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
-- analyze data from http://www.repole.com/sun4cast/data.html | |
raw_records = LOAD '/data/nfl/nfl2013lines.csv' USING PigStorage(','); | |
records = STREAM raw_records THROUGH `tail -n +2` AS | |
(Date, Visitor, VisitorScore:int, | |
HomeTeam, HomeScore:int, Line:float, TotalLine:float); | |
all_games = GROUP records ALL; | |
data = FOREACH all_games | |
GENERATE AVG(records.VisitorScore) as Visitor, AVG(records.HomeScore) as Home, AVG(records.Line) as Spread; | |
data2 = FOREACH data | |
GENERATE data.Home - data.Visitor as diff, data.Visitor, data.Home, data.Spread; |
This file contains 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
library(ggplot2) | |
set.seed(0.6) | |
grades <- rnorm(1500, mean = 75, sd = 12) | |
prob <- dnorm(grades, mean = 75, sd = 12) | |
below60 <- seq(from = min(grades), to = 60, by = .1) | |
below60d <- data.frame(x = below60, y = dnorm(below60, mean = 75, sd = 12)) | |
below60p <- rbind(c(min(grades), 0), | |
below60d, |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Test ElasticSearch</title> | |
</head> | |
<body> | |
<h1>Response to /_nodes</h1> | |
<p id="results"></p> | |
</body> | |
<script src="https://code.jquery.com/jquery-2.1.1.js"></script> |
This file contains 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
df <- data.frame(a = rep(1,100), b = rep(2, 100), c = rep(3, 100)) | |
m1 <- as.matrix(df) | |
m2 <- matrix(data = rep(1,3), nrow = 3) | |
res <- m1 %*% m2 |
This file contains 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
R> library(dplyr) | |
R> d <- data.frame(a=c(1,2,3), b=c(4,5,6)) | |
R> select(d, -a) | |
b | |
1 4 | |
2 5 | |
3 6 | |
R> |
This file contains 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
subs = Dir.new(".").select{|f| File.directory? f} | |
git_directories = subs.select{|d| Dir.exist? "#{d}/.git" } | |
task :update do | |
git_directories.each do |src_directory| | |
Dir.chdir(src_directory) do | |
sh "git pull origin master" | |
end | |
end | |
end |
This file contains 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
PrimeChecker.primes <- numeric() | |
PrimeChecker.nonPrimes <- numeric() | |
PrimeChecker.isPrime <- function(x) { | |
if(x < 2 || x %in% PrimeChecker.nonPrimes) { | |
return(FALSE) | |
} | |
if(x %in% PrimeChecker.primes) { | |
return(TRUE) | |
} |
This file contains 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
namespace :build do | |
build_configs = ["Debug", "Release"] | |
desc "build debug" | |
task "debug" do | |
sh build_cmd() | |
end | |
desc "build release" | |
task "release" do |
This file contains 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
skus = Dir.glob("*.jpg").collect do |file| | |
file.sub(".jpg","") | |
end | |
output = "final" | |
task :medium_images do | |
puts "creating medium images 250px wide..." | |
skus.each do |sku| | |
sh "convert #{sku}.jpg -strip -resize 250 -quality 100 #{output}/#{sku}_table.jpg" |