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(RCurl) | |
library(XML) | |
library(plyr) | |
#' get the Qualys SSL Labs rating for a domain+cert | |
#' | |
#' @param site domain to test SSL configuration of | |
#' @param ip address of \code{site} (will resolve it and take\cr | |
#' first response if not specified, but that may not always work as you expect) | |
#' @param pause timeout between tries (default 5s) |
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
require(redshift) | |
conn <- redshift.connect("jdbc:postgresql://mycluster.redshift.amazonaws.com:5439/data", "user", "pass") | |
# we can retrieve a list of tables | |
tables <- redshift.tables(conn) | |
# and get some info about the columns in one of those tables | |
cols <- redshift.columns(conn, "weblog") |
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 onOpen(){ | |
// example send for Sheets | |
sendGAMP("UA-XXXX-1", SpreadsheetApp.getActiveSpreadsheet().getUrl()); | |
// example send for Documents | |
//sendGAMP("UA-XXXX-1", DocumentApp.getActiveDocument().getUrl()); | |
// example send for Forms *NOTE* getUrl not implemented yet in New Sheets | |
//sendGAMP("UA-XXXX-1", FormApp.getActiveForm().getUrl()); | |
} |
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
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible). | |
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export. | |
var FORMAT_ONELINE = 'One-line'; | |
var FORMAT_MULTILINE = 'Multi-line'; | |
var FORMAT_PRETTY = 'Pretty'; | |
var LANGUAGE_JS = 'JavaScript'; | |
var LANGUAGE_PYTHON = 'Python'; |
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
######################################### | |
## GLOBAL REQUIREMENTS AND DEFINITIONS ## | |
######################################### | |
require(RCurl) | |
require(XML) | |
loginURL <- "https://accounts.google.com/ServiceLogin" | |
authenticateURL <- "https://accounts.google.com/accounts/ServiceLoginAuth" |
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
#################### | |
# Create relogit predicted probabilities using Zelig and ggplot2 | |
# Two Sword Lengths: Losers' Consent and Violence in National Legislatures (Working Paper 2012) | |
# Christopher Gandrud | |
# Updated 26 April 2012 | |
################### | |
## Load required packages | |
library(RCurl) | |
library(Zelig) |
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 Loading | |
library("RPostgreSQL"); | |
library("car"); | |
# Connect to Database | |
pgDrv <- dbDriver("PostgreSQL") | |
dbh <- dbConnect(pgDrv, host="localhost", dbname="dnsmonitor", user="dnsmon", password="tooEasy") | |
# Retrieve Statistics from DB | |
stats <- dbGetQuery(dbh, "select client.id, client.ip, sum(queries) as queries, sum(nx) as nx, sum(answers) as answers, sum(errors) as errors, count(distinct day) as days_active |
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
suppressMessages(library(forecast)) | |
data<-read.csv( file('stdin') ) | |
anomaly_detection<-function(data){ | |
seasonality<-48 | |
data_series<-ts(data$count,frequency=seasonality) | |
train_start<-1 ## train on 1 month of data |
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
ANOVA<-function(fit1,fit2){ | |
temp <- anova(fit2,fit1 ) | |
fin.aov <- anova(fit1) | |
reg <- temp[2,2:6] | |
rownames(reg) <- "Regression" | |
reg[1,1:2] <- reg[1,2:3] | |
reg[1,3] <- reg[1,2]/reg[1,1] | |
colnames(reg) <- colnames(fin.aov) | |
res <- fin.aov[tail(nrow(fin.aov),1),] | |
tot <- cbind(reg[1,1:2]+res[1,1:2],NA,NA,NA) |
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
N <- 10 | |
id <- 1:10 | |
x <- 1 + rnorm(N) - 1*id | |
date <- seq(as.Date("2013-07-01"), by = "year", along = x) | |
df <- data.frame(x = x, date = date) | |
plot(df$date, df$x) | |
summary(lm(x ~ date, data = df)) | |