Skip to content

Instantly share code, notes, and snippets.

View IronistM's full-sized avatar
🏗️
Under construction

Manos Parzakonis IronistM

🏗️
Under construction
View GitHub Profile
# 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
####################
# 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)
#########################################
## GLOBAL REQUIREMENTS AND DEFINITIONS ##
#########################################
require(RCurl)
require(XML)
loginURL <- "https://accounts.google.com/ServiceLogin"
authenticateURL <- "https://accounts.google.com/accounts/ServiceLoginAuth"
@IronistM
IronistM / exportjson.js
Created November 11, 2013 15:11 — forked from pamelafox/exportjson.js
functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// 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';
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());
}
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")
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)
library(ggplot2)
library(ggmap)
library(plyr)
library(grid)
library(gridExtra)
# read in cleaned up data
dat <- read.table("quakes.dat", header=TRUE, stringsAsFactors=FALSE)
# map decimal magnitudes into an integer range
# http://learnr.wordpress.com/2009/05/18/ggplot2-three-variable-time-series-panel-chart/
# http://www.talkstats.com/showthread.php/21228-time-series-in-ggplot2
# http://had.co.nz/ggplot2/
# http://stats.stackexchange.com/questions/14513/align-multiple-ggplot2-plots-with-grid
# http://wiki.stdout.org/rcookbook/Graphs/Facets%20(ggplot2)
# colors: red: "730202", lightyellow: D5D95B, lightgreen: 4F7302 midgreed=274001 darkgreen=092601
setwd('~/repositories/uni/thesis-repos/Opad4lsssExperiments/r_scripts/')
library(ggplot2)
library(gridExtra)
@IronistM
IronistM / pullJSON.js
Last active August 29, 2015 14:18 — forked from varun-raj/pullJSON.js
function pullJSON() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getActiveSheet();
var url="http://example.com/feeds?type=json"; // Paste your JSON URL here
var response = UrlFetchApp.fetch(url); // get feed
var dataAll = JSON.parse(response.getContentText()); //