Skip to content

Instantly share code, notes, and snippets.

@stedy
stedy / RSnquery.py
Created November 11, 2010 00:21
A script for getting ancestral alleles from dbSNP based on input list of RS #
#! usr/bin/python
#Filename: rsquery2.py
import re, urllib, time
rsnumbers = []
f = open('ancestral0624', 'a')
urltest = re.compile
prefix = "http://www.ncbi.nlm.nih.gov/projects/SNP/snp_ref.cgi?rs="
rsn = open("snplist")
@stedy
stedy / gs_knapsack.py
Created January 31, 2013 06:43
knapsack algorithm applied to Girl Scout cookies
from itertools import groupby
try:
xrange
except:
xrange = range
maxwt = 80
#weight, weight, value to me
groupeditems = (
@stedy
stedy / stopwatch.css
Created February 7, 2013 05:35
Use CSS to create two independent stopwatches in a webpage. Useful for meetings. Credit to thecodeplayer.com
* {margin: 0; padding: 0;}
body{
background: url('fakeexcel.png');
}
.container {
padding: 200px;
text-align: center;
}
@stedy
stedy / addcat.py
Created February 27, 2013 18:00
Script for adding picture pdf to a longer document
"""Split up a pdf, add an image, recombine pdf"""
from pyPdf import PdfFileWriter, PdfFileReader
from random import random
import argparse
def main():
parser = argparse.ArgumentParser(description = """Generate new pdf file
based on length of existing pdf""")
parser.add_argument('input_paper', help = """Input pdf of interest""")
@stedy
stedy / pip_update.py
Created February 14, 2014 22:53
Script to update all packages with pip. From https://stackoverflow.com/a/5839291/163809
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
call('pip install --upgrade ' + dist.project_name, shell = True)
@stedy
stedy / whois_lookup.py
Created February 18, 2014 23:02
Script to fetch WHOIS info on domain
from pywhois import whois
import argparse
parser = argparse.ArgumentParser(description= """whois lookup script""")
parser.add_argument('url', help = "URL of interest")
args = parser.parse_args()
print whois(args.url)
import tweepy
from random import randrange
auth = tweepy.OAuthHandler('API Key', 'API secret')
auth.set_access_token('Access token', 'Access token secret')
api = tweepy.API(auth)
sleep(randrange(0,3600)
@stedy
stedy / gas2014.csv
Created August 1, 2014 00:53
Gas efficiency analysis
Date Brand Mileage Cost Grade Amount TotalCost
1/3/2014 76 43159 3.499 87 4.985 17.44
1/13/2014 Arco 43415 3.29 87 9.205 30.28
1/18/2014 Shell 43655 3.499 87 9.521 33.31
1/22/2014 Costco 43938 3.179 87 9.28 29.5
1/28/2014 76 44201 3.499 87 9.263 32.41
2/15/2014 76 44434 3.499 87 9.434 33.01
3/5/2014 Shell 44664 3.699 87 9.801 36.25
3/16/2014 76 44917 3.519 87 9.014 31.72
3/21/2014 7-11 (Citgo) 45179 3.699 87 9.014 33.34
@stedy
stedy / LEGO.csv
Created August 30, 2014 23:26
Analysis of LEGO prices in 2014 & 1989
id pieces price collection
75059 3296 299.99 Star Wars
10221 3152 399.99 Star Wars
75037 178 14.99 Star Wars
75035 99 12.99 Star Wars
10188 3803 399.99 Star Wars
75036 83 12.99 Star Wars
75034 100 12.99 Star Wars
10240 1559 199.99 Star Wars
10225 2127 179.99 Star Wars
@stedy
stedy / summarize_LT.py
Created January 4, 2015 22:38
Summarize LibraryThing JSON data
import argparse
import datetime as dt
import json
import pandas as pd
import numpy as np
from ggplot import *
parser = argparse.ArgumentParser(description = """Yearly summary trends for
LibraryThing JSON data""")
parser.add_argument('json', help = "JSON file from LibraryThing")