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
elements <- c('the','story','was','the','point','of','the', | |
'story', 'a', 'quick','brown','fox','the','a', | |
'jumped','fence','over') | |
words <- sample(elements, 20000, replace = TRUE) | |
count <- function(word) { | |
sum(words == word) | |
} | |
# unique |
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
bits <- 1:8 | |
n <- 2 ^ bits | |
plot(n ~ bits, type = "b") |
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
-- 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 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
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 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
<!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 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
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 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
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 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
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 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
struct PrimeChecker { | |
static var nonPrimes: [Int] = [] | |
static var primes: [Int] = [] | |
func isPrime(x: Int) -> Bool { | |
if(x <= 1) { | |
return (false) | |
} | |
if(contains(PrimeChecker.nonPrimes, x)) { | |
return (false) |
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
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) | |
} |