Skip to content

Instantly share code, notes, and snippets.

View justinkamerman's full-sized avatar

Justin Kamerman justinkamerman

  • Instnt Inc.
  • Saint John, NB
View GitHub Profile
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
@justinkamerman
justinkamerman / hadoop-setup.sh
Created June 18, 2012 15:39
Cloud-init scripts for configuring a Ubuntu image for Hadoop
WRITE-MIME_MULTIPART=./bin/write-mime-multipart
.PHONY: clean
cloud-config.txt: ubuntu-config.txt hadoop-setup.sh
$(WRITE-MIME_MULTIPART) --output=$@ $^
clean:
$(RM) cloud-config.txt
@justinkamerman
justinkamerman / hitsbargraph.R
Created September 21, 2012 16:10
Generate hit statistics bar chart from Apache httpd access logs
#!/usr/bin/env Rscript
#
# Usage: $0 <apache_access_log>
#
# Generate hit statistics bar chart from Apache httpd access logs
#
d <- read.table ("access.dat")
colnames(d) <- c("ip", "path", "agent")
# Write column headers to data file
$ echo "t lt ts s lb rc rm tn dt by" > $DATAFILE
# Extract values in quotes
$ sed -n '/^<httpSample/{s/[^"]*\("[^"]*"\)[^"]*/\1 /gp}' $JTLFILE >> $DATAFILE
# Data file looks something like this...
$ head $DATAFILE
t lt ts s lb rc rm tn dt by
#!/usr/bin/env Rscript
#
# Usage: $0 <datafile>
#
# Expected data file format: t lt ts s lb rc rm tn dt by
#
myspan = 0.1
myargs <- commandArgs(TRUE)
file <- myargs[1]
@justinkamerman
justinkamerman / trace.py
Created October 12, 2012 16:16
Crawler for tracing retweet path
#!/usr/bin/python -u
#
# Usage: ./trace.py <tweetId>
#
import sys
import tweepy
import Queue
import time
import json
@justinkamerman
justinkamerman / retweet.html
Created October 12, 2012 17:13
D3 force direced graph script
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="d3.js"></script>
<style>
.link {
stroke: #ccc;
stroke-width: 2
}
for i in {1..1000}; do curl -o /dev/null -s -w "%{time_total}\n" http://mybaselineurl.com
for i in {1..100}; do curl -o /dev/null -s -w "%{time_total}\n" http://mynewurl.com