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 os | |
import re | |
import sys | |
from functools import partial | |
def f(host=u'', x=None): | |
""" | |
Returns string | |
""" |
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
Show hidden characters
[ | |
{ | |
"button": "button1", "modifiers": ["alt"], | |
"press_command": "drag_select", | |
"press_args": {"by": "columns"} | |
} | |
] |
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
# manage.py in Django project | |
import re | |
def read_env(): | |
""" | |
Pulled from Honcho code with minor updates, reads local default | |
environment variables from a .env file located in the project root | |
directory. | |
""" | |
try: |
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
v = 'True' | |
def bool2(): | |
v[0].lower() in ('t','1','y') |
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 csv | |
def csv_to_list(file_path): | |
""" | |
Reads csv file into list. | |
""" | |
with open(file_path, 'rb') as f: | |
# load all data into memory, scary | |
dialect = csv.Sniffer().sniff(f.read(1024)) | |
f.seek(0) # reset cursor |
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
from utils import json | |
from uuid import uuid4 | |
json.dumps({'id': uuid4()}) |
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
x = 'marks the spot' | |
def f(): | |
if False: | |
x = '' | |
print x |
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
SELECT COUNT(*) from information_schema.columns | |
WHERE table_name='forms_form'; |
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
# Used for lastname, firstname situations or | |
# when using incomplete addresses | |
# ', '.join() method doesn't account for blank items | |
# assumes string; else will break on strip method call | |
def commafy(*args, **kwargs): | |
delimiter = kwargs.get('delimiter', ', ') | |
return delimiter.join([i for i in args if i.strip()]) | |
# ideal world: whole address |
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
listify = lambda s='chicken egg',n=10: ((s+' ')*n).split() | |
listify() | |
listify('eloy') | |
listify('eloy',20) |