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
############################################################################### | |
# Author: @BrockTibert | |
# Purpose: Collect Historical NHL Skater Stats 1960 - 2011 (in progress) | |
# Date: February 2011 | |
# | |
# Used: R Version 2.12.1, Windows 7 Pro, StatET Plugin for Eclipse | |
# | |
# # Copyright (c) 2011, under the Simplified BSD License. | |
# For more information on FreeBSD see: http://www.opensource.org/licenses/bsd-license.php | |
# All rights reserved. |
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
# LOAD LIBRARIES REQUIRED | |
library(plyr); | |
library(XML) | |
# FIGURE OUT PATTERN OF URL FOR EACH SEASON | |
url.b1 = 'http://ca.sports.yahoo.com/nhl/stats/byposition?pos=C,RW,LW,D'; | |
url.b2 = '&sort=14&conference=NHL&year=season_'; | |
url.b3 = y; |
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 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 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
<?php | |
class makeExt{ | |
protected $project = "<project>"; | |
protected $name = "<you>"; | |
protected $desc = "<insert a short description here>"; | |
public function __construct(){ | |
global $argv, $argc; |
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
import nltk, glob | |
for filename in glob.glob( '*.htm*' ): | |
filein = open(filename) | |
html = filein.read() | |
raw = nltk.clean_html(html) | |
fileout = open(filename.rstrip('.html')+'.txt', 'w+') | |
fileout.write(raw) |
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
getPackage <- function(pkg){ | |
if(!require(pkg, character.only=TRUE)){ | |
install.packages(pkg, dependencies=TRUE) | |
library(pkg, character.only=TRUE) | |
} | |
return(TRUE) | |
} | |
getPackages <- function(pkgs){ | |
for (pkg in pkgs){ |
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
variable | Question | |
---|---|---|
cowcode | Correlates of War country code (www.correlatesofwar.org). | |
country | Country name. | |
systyear | Year in which the constitutional system was promulgated. | |
systid | Unique identification number for the constitutional system. | |
evntyear | Year of promulgation of the most recent constitutional event. | |
endyear | Year through which the data for the event is guaranteed valid. | |
evntid | Unique identification number for the constitutional event. | |
evnttype | Event type (e.g. amendment, new, etc.). | |
source | What is the source for the text of the Constitution? |
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
/* | |
You can create a spinner using either of the variants below: | |
$("#el").spin(true); //Starts the spinner. | |
$("#el").spin(false); // Kills the spinner. | |
*/ | |
(function($) { | |
$.fn.spin = function(opts) { |
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
function table2CSV(table, delim){ | |
var csv = "data:application/csv;charset=utf-8,"; | |
if(table instanceof HTMLElement){ | |
table = $(table); | |
} | |
if(table instanceof jQuery){ | |
var regex = /,/g; | |
if(delim){ | |
regex = new RegExp(delim, 'g'); | |
delim = encodeURIComponent(delim); |
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
#' @title PRESS | |
#' @author Thomas Hopper | |
#' @description Returns the PRESS statistic (predictive residual sum of squares). | |
#' Useful for evaluating predictive power of regression models. | |
#' @param linear.model A linear regression model (class 'lm'). Required. | |
#' | |
PRESS <- function(linear.model) { | |
#' calculate the predictive residuals | |
pr <- residuals(linear.model)/(1-lm.influence(linear.model)$hat) | |
#' calculate the PRESS |
OlderNewer