Skip to content

Instantly share code, notes, and snippets.

View garrettr's full-sized avatar

Garrett Robinson garrettr

  • San Francisco, CA
View GitHub Profile
@garrettr
garrettr / gist:1362441
Created November 13, 2011 18:17
S3 Upload w/ Boto
def upload_to_s3(local_file, bucket_name, key_name=None, acl='private'):
'''
Uploads local_file to bucket_name on Amazon S3
key_name is the "filename" on Amazon S3. We'll default to the local file's name if
no alternative key_name is specified.
'''
# connect to Amazon S3
conn = S3Connection(AWS_ACCESS_KEY, AWS_SECRET_KEY)
bucket = conn.create_bucket(bucket_name)
@garrettr
garrettr / check_email.py
Created November 17, 2011 21:05
Receiving emails with Django and Webfaction
from django.core.management.base import BaseCommand, CommandError
from news.models import Post
from django.core.files import File
from django.conf import settings
from feincms.module.medialibrary.models import MediaFile
import sys, os
import imaplib
import email
@garrettr
garrettr / gist:2919669
Created June 12, 2012 19:39
Universal Makefile for Statmap
CC=clang
CFLAGS=-O3 -msse2 -Wall -Wextra -D_FILE_OFFSET_BITS=64
objects := $(patsubst %.c,%.o,$(wildcard *.c))
all: statmap statmap.so
statmap: $(objects)
$(CC) -o statmap \
$(objects) \
$(CFLAGS) \
-lm -lpthread
@garrettr
garrettr / gist:3157324
Created July 21, 2012 21:51
Bash Prompt
# Bold green prompt
# ~ >
export PS1="\[\e[1;32m\]\W > \[\e[m\]"
# Officially the coolest prompt ever (inverted black-on-green \W)
export PS1="\[\e[7;32m\]\W \$\[\e[m\] "
# for more: http://jamiedubs.com/ps1-collection-customize-your-bash-prompt/
@garrettr
garrettr / gist:3628225
Created September 4, 2012 23:53
Statmap Gapped Reads Timeline
# Plan for finishing Gapped Reads Mapping
Here is the remaining work that needs to be done to map gapped reads (RNASeq) with Statmap.
1. [x] Change the binary search in find_matching_mapped_locations to return as matches all locations within a range (REFERENCE_INSERT_LENGTH_MAX in config.h) including and beyond the base location's start.
Done on: 8/31/12
2. [x] Handle multiple matches in the candidate mapping building. Storing them is easy (we used a mapped_locations from the beginning with this in mind).
Done on: 9/3/12
Once that is done, we will have a set of candidate mappings, as we had before. The next step is to rework the recheck. As preparation, the first step is
@garrettr
garrettr / db_ex.py
Created March 14, 2013 17:31
Joined table inheritance with SQLAlchemy
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_pyfile('settings.cfg')
db = SQLAlchemy(app)
class User(db.Model):
__tablename__ = 'users'
@garrettr
garrettr / gist:5988727
Created July 12, 2013 23:59
Probability of a specific hash collision
In [1]: from __future__ import division
In [2]: n = 2**32
In [3]: p = 1 - ((n-1)/n)**1000000000
In [4]: p
Out[4]: 0.2077122589016286
@garrettr
garrettr / wordlist_math.py
Created December 2, 2013 01:25
SecureDrop Wordlist Rainbow Table Math
#!/usr/bin/env python
import sys
wordlist_filename = sys.argv[1]
words = []
with open(wordlist_filename) as wl_fp:
for line in wl_fp:
words.append(line.strip())
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I, Garrett Robinson, downloaded the Qubes signing key on
Sun Apr 6 16:11:37 PDT 2014
from
https://keys.qubes-os.org/keys/qubes-developers-keys.asc
@garrettr
garrettr / logUserStored.diff
Created May 14, 2014 00:27
Log userStored for Privacy Badger Firefox
diff --git a/lib/userStorage.js b/lib/userStorage.js
index 5441382..5cca0cc 100644
--- a/lib/userStorage.js
+++ b/lib/userStorage.js
@@ -104,6 +104,10 @@ exports.init = function()
if (!storage[store]) storage[store] = {};
}
);
+ // Log JSON out to the console for cooperq
+ userStored.forEach(function(store) {