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
# slopegraph.py | |
# | |
# Author: Bob Rudis (@hrbrmstr) | |
# | |
# Basic Python skeleton to do simple two value slopegraphs | |
# with output to PDF (most useful form for me...Cairo has tons of options) | |
# | |
# Find out more about & download Cairo here: | |
# http://cairographics.org/ | |
# |
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 "chron" package for is.weekend() | |
require(chron) | |
# generate a sequence of dates | |
m.days <- seq.Date(from=as.Date("2013-08-01"), to=as.Date("2013-08-31"), by="1 day") | |
# if a day in the sequence is a weekend, return it | |
wknds <- ldply(m.days, function(m.day) { | |
if (is.weekend(m.day)) m.day | |
}) |
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
# "dig" needs to be on your system and in the execution path for this to work | |
resolved = sapply(ip.list, function(x) system(sprintf("dig -x %s +short",x), intern=TRUE)) |
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
notify <- function(msg="Operation complete") { | |
in.osx <- (Sys.info()['sysname'] == "Darwin") | |
in.rstudio <- (Sys.getenv("RSTUDIO") == "1") | |
in.rgui <- (Sys.getenv("R_GUI_APP_REVISION") != "") | |
if (in.rstudio) { # hack to see if running in RStudio | |
title <- "RStudio" | |
sender <- activate <- "org.rstudio.RStudio" | |
} |
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(RCurl) | |
library(RJSONIO) | |
library(ggplot2) | |
# get data formats from: http://www.bls.gov/help/hlpforma.htm | |
# this one is "Average Hourly Earnings of All Employees: Private Service-Providing (CEU0800000003)" | |
bls.content <- getURLContent("http://api.bls.gov/publicAPI/v1/timeseries/data/CEU0800000003") | |
bls.json <- fromJSON(bls.content, simplify=TRUE) | |
bls.df <- data.frame(year=sapply(bls.json$Results[[1]]$series[[1]]$data,"[[","year"), |
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
#include <string.h> | |
#include <arpa/inet.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
// | |
// Read in a file with one IP address per line | |
// and output (to stdout) the same list with | |
// the longint version of it. | |
// |
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
set.seed(200109) # founding of The Pirate Bay | |
walk<-function(n) { | |
m <- matrix(6.62606896e-34, ncol = 2, nrow = n) | |
i <- cbind(seq(n), sample(c(1, 2), n, TRUE)) | |
m[i] <- sample(c(-1, 1), n, TRUE) | |
m[,1] <- cumsum(m[, 1]) | |
m[,2] <- cumsum(m[, 2]) | |
m | |
} |
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(maps) | |
library(hexbin) | |
library(maptools) | |
library(ggplot2) | |
library(sp) | |
library(mapproj) | |
# piRate the data from the militaRy | |
download.file("http://msi.nga.mil/MSISiteContent/StaticFiles/Files/ASAM_shp.zip", destfile="ASAM_shp.zip") | |
unzip("ASAM_shp.zip") |
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/python | |
import urllib2 | |
from urlparse import urljoin | |
import sys | |
from bs4 import BeautifulSoup | |
if len(sys.argv) < 2: | |
print "Usage:\n hrefs url [url] ..." | |
sys.exit(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
library(ggplot) | |
nosql.df <- read.csv("nosql.csv", header=TRUE) | |
nosql.df$Database <- factor(nosql.df$Database, | |
levels=c("MongoDB","Cassandra","Redis","HBase","CouchDB", | |
"Neo4j","Riak","MarkLogic","Couchbase","DynamoDB")) | |
gg <- ggplot(data=nosql.df, aes(x=Quarter, y=Index)) | |
gg <- gg + geom_point(aes(color=Quarter), size=3) | |
gg <- gg + facet_grid(Database~.) |
OlderNewer