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
draft.sequence <- c() | |
rep.count <- floor((num.teams*15)/(2*num.teams)) | |
draft.order <- rep(c(1:num.teams, rev(1:num.teams)), rep.count) | |
draft.order <- c(draft.order, 1:num.teams) | |
#Function for | |
make.pick <- function(team_num) { | |
team <- teams[[team_num]] | |
selection.made <- FALSE | |
selection.index <- 1 |
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
# Model only works for 15-man rosters with this format of players! | |
num.teams <- 10 | |
qb <- 1 | |
rb <- 2 | |
wr <- 2 | |
te <- 1 | |
flex <- 1 | |
def <- 1 | |
pk <- 1 | |
bench <- 6 |
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(yhatr) | |
model.require <- function() { | |
library(plyr) | |
} | |
model.transform <- function(df) { | |
df | |
} |
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
ur1twt.py | |
Description: Retweets random people's first ever tweet. Fun! | |
Created by ([email protected]) on | |
# Copyright (c) , under the Simplified BSD License. | |
# For more information on FreeBSD see: http://www.opensource.org/licenses/bsd-license.php |
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
# Get a lat/lon value for each address | |
geocode.addr <- function(city, country) { | |
geo.url <- "http://maps.googleapis.com/maps/api/geocode/json?address=" | |
geo.text <- getURL(paste(geo.url, URLencode(paste(city, country, collapse="+")), "&sensor=false", sep="")) | |
geo.json <- fromJSON(geo.text) | |
if(geo.json$status == "OK"){ | |
return(geo.json$results[[1]]$geometry$location) | |
} | |
else{ |
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
# Generate digitial clock face | |
first.nine <- c('00', '01', '02', '03', '04', '05', '06', '07', '08', '09') | |
hours <- c(first.nine, as.character(seq(10,23,1))) | |
mins <- c(first.nine, as.character(seq(10,59,1))) | |
time.chars.l <- lapply(hours, function(h) paste(h, ':', mins, sep='')) | |
time.chars <- do.call(c, time.chars.l) | |
# Generate analog clock face | |
hour.pos <- seq(0, 12, 12/(12*60))[1:720] | |
min.pos <-seq(0,12, 12/60)[1:60] |
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
# Generate digitial clock face | |
first.nine <- c('00', '01', '02', '03', '04', '05', '06', '07', '08', '09') | |
hours <- c(first.nine, as.character(seq(10,23,1))) | |
mins <- c(first.nine, as.character(seq(10,59,1))) | |
time.chars.l <- lapply(hours, function(h) paste(h, ':', mins, sep='')) | |
time.chars <- do.call(c, time.chars.l) | |
# Generate analog clock face | |
hour.pos <- seq(0, 12, 12/(12*60))[1:720] | |
min.pos <-seq(0,12, 12/60)[1:60] |
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
import networkx as nx | |
from networkx.readwrite import d3_js | |
mikedewar = nx.read_graphml('mikedewar_rec.graphml') | |
# We need to relabel nodes as Twitter name if we want to show the names in the plot | |
label_dict = dict(map(lambda i : (mikedewar.nodes()[i], mikedewar.nodes(data=True)[i][1]['Label']), xrange(mikedewar.number_of_nodes()))) | |
mikedewar_d3 = nx.relabel_nodes(mikedewar, label_dict) | |
# Export |
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
import smtplib | |
from datetime import datetime | |
def noticeEMail(starttime, usr, psw, fromaddr, toaddr): | |
""" | |
Sends an email message through GMail once the script is completed. |
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
# For this exercise we assume to draw random points inside the square on the [-1,1] unit, | |
# and thus the value of Pi = 4(# random pts insid cirlce / # random pts in square) | |
sim.pi <- function(iterations = 1000) { | |
# Generate two vectors for random points in unit circle | |
x.pos <- runif(iterations, min=-1, max=1) | |
y.pos <- runif(iterations, min=-1, max=1) | |
# Test if draws are inside the unit circle | |
draw.pos <- ifelse(x.pos^2 + y.pos^2 <= 1, TRUE, FALSE) | |
draws.in <- length(which(draw.pos == TRUE)) | |
# Estimate Pi |
NewerOlder