Skip to content

Instantly share code, notes, and snippets.

@ehazlett
ehazlett / slideshow_creator.py
Created May 17, 2011 04:28
Gnome wallpaper slideshow creator
#!/usr/bin/env python
import os
import sys
import logging
from datetime import date
from optparse import OptionParser
IMAGE_TYPES = [
'png',
@ehazlett
ehazlett / pub_med.py
Created July 25, 2011 16:27
Search PubMed with BioPython
#!/usr/bin/env python
# numpy and biopython are required -- pip install numpy biopython
from Bio import Entrez
from Bio import Medline
MAX_COUNT = 10
TERM = 'Tuberculosis'
print('Getting {0} publications containing {1}...'.format(MAX_COUNT, TERM))
@ehazlett
ehazlett / transcribe.py
Created December 27, 2011 01:02
Logs Redis Pub/Sub messages to MongoDB
#!/usr/bin/env
#
# Requirements:
# argparse==1.2.1
# pymongo==2.1
# redis==2.4.10
import redis
import pymongo
import argparse
@ehazlett
ehazlett / find_in_sorted.py
Created January 11, 2012 15:52
Find in Sorted
def find_in_sorted(arr, x):
'''
Returns index of x in arr
Precondition: arr is sorted
'''
def binsearch(start, end):
mid = start + (end - start) // 2
if start == end:
return -1
if x < arr[mid]:
@ehazlett
ehazlett / gist:1754289
Created February 6, 2012 19:34
AWS EBS Volume Cleanup
#!/usr/bin/env python
from optparse import OptionParser
import boto.ec2
import logging
import sys
def get_ec2_connection(aws_key=None, aws_secret=None, region='us-east-1'):
"""
Returns an EC2Connection to the specified region
@ehazlett
ehazlett / tomcat.pp
Created February 13, 2012 03:19
Tomcat Puppet
class tomcat {
$tomcat_url = "http://mirrors.axint.net/apache/tomcat/tomcat-7/v7.0.25/bin/apache-tomcat-7.0.25.tar.gz"
$jdk_url = "http://download.oracle.com/otn-pub/java/jdk/6u25-b06/jdk-6u25-linux-x64.bin"
Exec {
path => "${::path}",
}
group { "puppet":
ensure => present,
}
@ehazlett
ehazlett / redis.conf
Created February 13, 2012 15:32
Redis supervisor config
[program:redis]
command=/usr/local/bin/redis-server /storage/redis_data/redis.conf
directory=/storage/redis_data
user=root
autostart=false
stopsignal=QUIT
@ehazlett
ehazlett / mongodb.conf
Created February 13, 2012 15:32
MongoDB supervisor config
[program:mongodb]
command=/opt/mongodb/bin/mongod --dbpath /storage/mongodb_data --rest
directory=/opt/mongodb
user=root
autostart=false
@ehazlett
ehazlett / coiapi_benchmarks.txt
Created February 15, 2012 21:21
COIAPI Benchmarks
Benchmarks for COI API using ApacheBench
Tests performed using apache bench from Intech network using a wired connection.
API Host: t1.micro - ec2-184-72-205-178.compute-1.amazonaws.com
MongoDB Host: m1.large - ec2-23-20-88-122.compute-1.amazonaws.com
Redis Host: t1.micro - ec2-184-72-205-178.compute-1.amazonaws.com (same as API host)
-----
1000 req with 100 concurrent to Redis
@ehazlett
ehazlett / tomcat7_elasticbeanstalk.txt
Created February 21, 2012 03:02
New Relic with Tomcat 7 on ElasticBeanstalk
-javaagent:/opt/tomcat7/webapps/ROOT/WEB-INF/lib/newrelic.jar