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 UserNameValidator(object): | |
"""A simple user name validator to prohibit banned words""" | |
not_allowed = set(['parrot','dog','kitten','ibis',]) | |
substitutions = {'1':'i','0':'o','7':'t'} | |
def is_valid(self, name): | |
name = name.lower() | |
#Substitute values as needed in name | |
for find,replace in UserNameValidator.substitutions.items(): |
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 sys | |
from time import time | |
from PIL import Image | |
import numpy as np | |
from scipy.ndimage.filters import generic_filter, gaussian_filter | |
def trace(fn): | |
"""A decorator to time your functions""" |
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 itertools | |
def crosstab(rows, columns, col_idx_for_columns, lst_col_idx_for_rows, value_col_idx, fill_val, format_func=None): | |
"""Take col_idx_to_cross_tab and make its unique values be new columns at the end filled with | |
value_col_idx values. col idx arguments are 0 based. | |
This is basically a simplified pivot table creator with the limitations that you can only have one field in the columns | |
and there is no aggregation. | |
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 re | |
import datetime | |
from time import time | |
import sys | |
import math | |
import zipfile | |
import pickle | |
from cStringIO import StringIO | |
from dateutil.relativedelta import relativedelta |
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
/* | |
name: | |
mv: | |
app: | |
note: | |
*/ |
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 re | |
import datetime | |
import math | |
def format_timeinterval(start, end=None): | |
if not end: | |
end = datetime.now() | |
return format_timedelta(end - start) | |
def format_secondsdelta(seconds): |
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
"""""" | |
Sample script using Lyons ABA web service methods | |
"""""" | |
import httplib | |
import urllib | |
import xml.dom.minidom | |
#-------SETTINGS------- |
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
--Log Insert | |
CREATE TRIGGER LogInsert ON [dbo].[CustomerProduct] | |
FOR INSERT | |
AS | |
INSERT changelog SELECT TOP 1 getdate(), 'Insert', 'CustomerProduct', CustomerID, ProductID, 'PaymenttypeID', '', Paymenttypeid FROM inserted | |
INSERT changelog SELECT TOP 1 getdate(), 'Insert', 'CustomerProduct', CustomerID, ProductID, 'ExpirationDate', '', convert(varchar(12), ExpirationDate, 110) FROM inserted | |
INSERT changelog SELECT TOP 1 getdate(), 'Insert', 'CustomerProduct', CustomerID, ProductID, 'Rate', '', Rate FROM inserted |
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
Perl syntax basics: | |
Perl === | |
Start interactive interpreter: | |
perl -de 1 | |
==== Syntax Basics ==== | |
<pre><nowiki> | |
data types: $scalars, @lists, and %hashes | |
""my"" makes a variable be in the scope of its block and lower. Use ""our"" for globals. | |
Put ""use strict"" at beginning of file to be required to declare variables. |
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
"""Quick functions for reading and writing FASTQ""" | |
def read_fastq(filehandle): | |
''' Return dictionary with 'seq_id', 'seq', 'qual_id', and 'qual' ''' | |
record_line = 0 | |
read_number = 0 | |
fastq_record = dict() | |
for line in filehandle: | |
record_line += 1 |
NewerOlder