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
from BeautifulSoup import BeautifulStoneSoup | |
import subprocess | |
import sys | |
import tempfile | |
def extract_pdf_title(pdfdata): | |
src_file = tempfile.NamedTemporaryFile(delete=True) | |
src_file.write(pdfdata) | |
src_file.flush() |
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
require('ggplot2') | |
require('stringr') | |
FIELDS = c('frame.time_relative', 'frame.len', | |
'ip.src', 'tcp.srcport', 'udp.srcport', | |
'ip.dst', 'tcp.dstport', 'udp.dstport') | |
PCAP = 'nytimes.pcap' | |
TSHARK = paste('tshark','-E header=y', '-T fields') | |
data = read.csv(header=T, sep="\t", pipe( |
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/env python | |
import collections, glob, os, re | |
from dateutil.parser import * | |
sentmail_mbox = glob.glob(os.path.expanduser('~/.thunderbird/*/ImapMail/*/*/Sent Mail')) | |
lines = [] | |
for mbox in sentmail_mbox: | |
lines.extend(open(mbox).read().split('\n')) |
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("ggplot2") | |
library("reshape") | |
getData = function() { | |
SOURCE=Sys.glob('/home/power/.thunderbird/*/*/*/*/Sent Mail') | |
return(readLines(SOURCE)) | |
} | |
getMatches = function(data) { | |
matched_lines = grep('^Date:.*, .*-0\\d+', data, value=T) |
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
require("maps") | |
require("ggplot2") | |
require("sp") | |
census_data = "ACS_10_1YR_S1901/ACS_10_1YR_S1901_with_ann.csv" | |
t = read.csv(census_data, skip=6) | |
sinfo = data.frame(region=t$Geography, | |
mean=t$Estimate.48, | |
median=t$Estimate.44, |
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
from threading import Thread | |
import cProfile | |
import pstats | |
def enable_thread_profiling(): | |
'''Monkey-patch Thread.run to enable global profiling. | |
Each thread creates a local profiler; statistics are pooled | |
to the global stats object on run completion.''' |
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
class FileWatchdog(threading.Thread): | |
"""Watchdog for a file (typically `sys.stdin`). | |
When the file closes, terminate the process. | |
(This typically occurs when the parent process is lost.) | |
""" | |
def __init__(self, file_handle): | |
threading.Thread.__init__(self, name='WatchdogThread') | |
self.setDaemon(True) | |
self.file_handle = file_handle |
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/env python | |
""" | |
Compare speed of several methods of copying data between two GPU devices. | |
""" | |
import atexit, ctypes, re, time | |
import numpy as np | |
import pycuda.driver as drv | |
import pycuda.gpuarray as gpuarray |
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
import pylab | |
import pandas as P | |
import numpy as np | |
def draw_array(a, target=None): | |
fig = pylab.gcf() | |
fig.frameon = False | |
ax = fig.gca() | |
#ax.set_axis_off() |
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
<!DOCTYPE html> | |
<!-- Some path computation code borrowed form http://bl.ocks.org/rkirsling/5001347 --> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<title>Transaction Chain Viz</title> | |
<script type='text/javascript' src='http://d3js.org/d3.v3.min.js'></script> | |
<script type='text/javascript' src='http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.2.1/lodash.min.js'></script> | |
<script type='text/javascript' src='http://cpettitt.github.io/project/dagre-d3/latest/dagre-d3.min.js'></script> |
OlderNewer