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
client <- function(){ | |
while(TRUE){ | |
con <- socketConnection(host="localhost", port = 6011, blocking=TRUE, | |
server=FALSE, open="r+") | |
f <- file("stdin") | |
open(f) | |
print("Enter text to be upper-cased, q to quit") | |
sendme <- readLines(f, n=1) | |
if(tolower(sendme)=="q"){ | |
break |
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) | |
library(OpenStreetMap) | |
merc <- projectMercator(df2$lat, df2$lng) #OSM uses mercator | |
# give openmap the upper right and lower left corners you want for your map | |
mp <- openmap(c(42.05, -87.96), c(41.62, -87.5), type="osm", minNumTiles=16) | |
p <- autoplot(mp) + geom_point(aes(x=merc[,1], y=merc[,2]), alpha=.7, size=10) + | |
theme(line = element_blank(), | |
text = element_blank(), | |
line = element_blank(), |
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(httr) | |
# 1. Find OAuth settings for yahoo: | |
# Endpoints described here... | |
# http://developer.yahoo.com/oauth/guide/oauth-auth-flow.html | |
yahoo <- oauth_endpoint("get_request_token", "request_auth", "get_token", | |
base_url = "https://api.login.yahoo.com/oauth/v2/") | |
# 2. Register an application at... | |
# https://developer.apps.yahoo.com/dashboard/createKey.html |
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(XML) | |
library(httr) | |
url1 <- "http://www.district87.org/pages/Bloomington_School_District_87/Parents_and_Students/Bus_Routes/Bloomington_High_School" | |
x <- GET(url1) | |
text <- content(x, as="text") | |
doc <- htmlParse(text) | |
a <- xpathSApply(doc, "//table[@id='fsvItemsTable']/tr") | |
links <- xpathSApply(a[[1]], "//a/@href") | |
links <- links[grepl("^/files", links)] |
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
# create a plot of my game outcomes. | |
p1 <- ggplot(my.df, aes(x=game, y=score, color=team, group=team)) + | |
geom_point() + geom_line() + scale_y_continuous() | |
ggsave("FF_regular_season.jpg") |
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
my.df <- data.frame(cbind(game=rep(1:length(my.score), 2), | |
team=c(rep("me", length(my.score)), rep("them", length(my.score))), | |
score=as.numeric(c(my.score, opp.score)))) | |
my.df$game <- factor(my.df$game, levels=1:13) | |
my.df$score <- as.numeric(as.character(my.df$score)) |
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
my.team.matchups.json <- GET(paste0(team.url, my.team.key, | |
"/matchups?format=json"), sig) | |
my.team.matchups.list <- fromJSON(as.character(my.team.matchups.json), asText=T) | |
# get the opponent scores for my matchups for the entire season | |
tmp <- my.team.matchups.list$fantasy_content["team"][[1]][[2]]$matchups | |
opp.score <- tmp$'0'$matchup$`0`$teams$`1`$team[[2]]$team_points["total"] | |
opp.score <- c(opp.score, sapply(as.character(1:12), | |
function(x)tmp[x][[x]]$matchup$`0`$teams$`1`$team[[2]]$team_points$total)) | |
my.score <- tmp$'0'$matchup$`0`$teams$`0`$team[[2]]$team_points["total"] |
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(httr) | |
# saved my yahoo keys to a file, now, read them in... | |
creds <- read.table("~/cn/personal/keys/yahoo.txt", stringsAsFactors=F) | |
consumer.key <- creds[1,1] | |
consumer.secret <- creds[2,1] | |
token.url <- "https://api.login.yahoo.com/oauth/v2/" | |
yahoo <- oauth_endpoint("get_request_token", "request_auth", "get_token", | |
base_url = token.url) |
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
# need to get game id for my league... | |
ff.url <- "http://fantasysports.yahooapis.com/fantasy/v2/game/nfl?format=json" | |
game.key.json <- GET(ff.url, sig) | |
game.key.list <- fromJSON(as.character(game.key.json), asText=T) | |
game.key <- game.key.list$fantasy_content$game[[1]]["game_key"] | |
# my personal leagueid, you will have to use your own, mine is private | |
league.id <- "418826" | |
league.key <- paste0(game.key, ".l.", league.id) | |
league.url <- "http://fantasysports.yahooapis.com/fantasy/v2/league/" |
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 socket | |
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
client_socket.connect(("localhost", 6011)) | |
while 1: | |
data = raw_input ( "Enter text to be upper-cased, q to quit\n" ) | |
client_socket.send(data) | |
if ( data == 'q' or data == 'Q'): | |
client_socket.close() | |
break; |
NewerOlder