Skip to content

Instantly share code, notes, and snippets.

View sammyrulez's full-sized avatar

Sam Reghenzi sammyrulez

View GitHub Profile
@sammyrulez
sammyrulez / create_django_gondor_project.sh
Created August 31, 2011 09:09
script to create a django project bound to gondor.io deploy
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Error in $0 - Invalid Argument Count"
echo "Syntax: $0 project_name gondor_app_id"
exit
fi
@sammyrulez
sammyrulez / create_django_heroku_project.sh
Created September 12, 2011 10:07 — forked from tkopczuk/create_django_heroku_project.sh
Script to create a new Heroku-ready Django project.
#!/bin/bash
if [ $# -ne 2 ]
then
echo "Error in $0 - Invalid Argument Count"
echo "Syntax: $0 project_name desidered_heroku_name"
exit
fi
project_name=$1
@sammyrulez
sammyrulez / vigenere.py
Created December 14, 2011 09:35
Vigenère cipher python functions
from string import ascii_lowercase
def buildmap():
table = {}
for x in range(0,len(ascii_lowercase)):
row = {}
c = 0
for y in range(0,len(ascii_lowercase)):
row[ascii_lowercase[y]] = ascii_lowercase[x+y+c]
if x+y > 24:
@sammyrulez
sammyrulez / eqsub.py
Created December 30, 2011 13:34
Equal Sum Substring
def getEqualSumSubstring (s):
substrings = get_all_subsets(s)
for subsr in substrings:
if check_string(subsr):
return len(subsr)
return 0
@sammyrulez
sammyrulez / .gitignore
Created January 9, 2012 14:56
ignore for python projects
*.mo
*.egg-info
*.egg
*.EGG
*.EGG-INFO
bin
*_py_env
build
develop-eggs
downloads
@sammyrulez
sammyrulez / sieve.py
Created February 2, 2012 09:25
Sieve of Eratosthenes
def compute(n=100):
seq = range(2,n)
p = 2
while p < n and len(range(2*p,n,p)):
jumpy = range(2*p,n,p)
for j in jumpy:
if seq.count(j) > 0:
seq.remove(j)
@sammyrulez
sammyrulez / build.gradle
Created February 9, 2012 12:08
Grails 2.0 gradle build
grailsVersion = '2.0.0'
buildscript {
repositories {
mavenCentral()
mavenRepo urls: 'http://snapshots.repository.codehaus.org'
mavenRepo urls: 'http://download.java.net/maven/2/'
mavenRepo name: "Grails Repo", urls: "http://repo.grails.org/grails/repo"
}
@sammyrulez
sammyrulez / match.py
Created April 26, 2012 15:24
Reverse protein matcher
from Bio.Data import CodonTable
def full_back_table(codon_table):
base_table = codon_table.forward_table
out_table = {}
for codon in base_table:
p = base_table[codon]
if out_table.has_key(p):
out_table[p].append(codon)
else:
@sammyrulez
sammyrulez / merge.py
Created May 4, 2012 15:26
print merge csv and jinja template
# -*- coding: utf-8 -*-
import csv
from jinja2 import Environment, FileSystemLoader
def read_input(csvfile , ):
csvfile_v = open(csvfile, "rb")
dialect = csv.Sniffer().sniff(csvfile_v.read(1024))
csvfile_v.seek(0)
reader = csv.DictReader(csvfile_v, dialect=dialect)
return reader
def get_mismatch_list(base_query, mismatch_n):
for i, ch in enumerate(base_query):
gap_filler = ""
out_str = ""
for m in range(0, mismatch_n):
true_index = i + m
if true_index >= len(base_query):
true_index = true_index - len(base_query)
target_element = base_query[true_index]
print 'target ', target_element