Skip to content

Instantly share code, notes, and snippets.

View gsiegman's full-sized avatar

Glenn Siegman gsiegman

  • Wisconsin
  • 16:13 (UTC -05:00)
View GitHub Profile
phone_char_mappings = {
'A': '2', 'B': '2', 'C': '2',
'D': '3', 'E': '3', 'F': '3',
'G': '4', 'H': '4', 'I': '4',
'J': '5', 'K': '5', 'L': '5',
'M': '6', 'N': '6', 'O': '6',
'P': '7', 'R': '7', 'S': '7',
'T': '8', 'U': '8', 'V': '8',
'W': '9', 'X': '9', 'Y': '9',
'1': '1', '2': '2', '3': '3',
@gsiegman
gsiegman / 99bottles
Created November 25, 2011 22:01
99 Bottles of Beer on the Wall
import os
"""OS X only"""
def sing():
for i in range(0, 99):
num = 99 - i
os.system("say %s bottles of beer on the wall, %s bottles of beer, if one of those bottles should happen to fall, %s bottles of beer on the wall" % (num, num, num-1))
if __name__ == '__main__':
@gsiegman
gsiegman / gist:1504249
Created December 21, 2011 02:15
Python List of Noise Words
NOISE_WORDS = [
"a","about","above","all","along","also","although","am","an","any","are","aren't",
"as","at","be","because","been","but","by","can","cannot","could","couldn't",
"did","didn't","do","does","doesn't","e.g.","either","etc","etc.","even","ever",
"for","from","further","get","gets","got","had","hardly","has","hasn't","having","he",
"hence","her","here","hereby","herein","hereof","hereon","hereto","herewith","him",
"his","how","however","I","i.e.","if","into","it","it's","its","me","more","most",
"mr","my","near","nor","now","of","on","onto","other","our","out","over","really",
"said","same","she","should","shouldn't","since","so","some","such","than","that",
"the","their","them","then","there","thereby","therefore","therefrom","therein",
@gsiegman
gsiegman / gist:1604586
Created January 13, 2012 03:43
Naughty Words
NAUGHTY_WORDS = [
"ass", "asswipe", "asshole", "anal", "azz", "bastard", "BDSM", "bitch", "biotch",
"beetch", "boob", "b00b", "blowjob", "boxmunching", "bullshita", "butthead",
"butthole", "clit", "cock", "cum", "cunnilingus", "cunt", "dick", "dike", "dildo",
"dink", "dong", "douche", "dumbass", "dung", "fag", "faggot", "fart", "fop", "fuck",
"fuk", "fing", "gangbang", "gay", "go black", "homo", "goddamn", "hoochie", "hooters",
"horny", "horney", "jacking", "jackoff", "jerking", "jism", "knockers", "kunt", "lesbo",
"manmeat", "manwich", "masturbate", "masterbate", "moron", "muff", "muffdive", "muncher",
"nigger", "nympho", "orgy", "pecker", "penus", "penis", "piss", "prick", "pussy", "rectum",
"rectal", "scrotum", "schlong", "shit", "slit", "slut", "sob", "tits", "twat", "whore",
@gsiegman
gsiegman / Procfile
Created February 26, 2012 02:52
My Heroku Procfile
web: python django_project/manage.py collectstatic --noinput; bin/gunicorn_django --workers=3 --bind=0.0.0.0:$PORT django_project/settings.py
@gsiegman
gsiegman / gist:1918836
Created February 26, 2012 20:27
Rounding with string homework
#Given a variable, x, that stores
#the value of any decimal number,
#write Python code that prints out
#the nearest whole number to x.
#You can assume x is not negative.
# x = 3.14159 -> 3 (not 3.0)
# x = 27.63 -> 28 (not 28.0)
#Given a variable, x, that stores
#the value of any decimal number,
#write Python code that prints out
#the nearest whole number to x.
#You can assume x is not negative.
# x = 3.14159 -> 3 (not 3.0)
# x = 27.63 -> 28 (not 28.0)
<input name="" type="text" class="inputbox" value="Search" onblur=
"this.value=(this.value=='') ? 'Search' : this.value;" onfocus=
"this.value=(this.value=='Search') ? '' : this.value;" />
@register.filter()
def currency(value):
symbol = getattr(settings, 'CURRENCY_SYMBOL', '$')
thousand_sep = getattr(settings, 'THOUSAND_SEPARATOR', ',')
decimal_sep = getattr(settings, 'DECIMAL_SEPARATOR', '.')
intstr = str(int(value))
f = lambda x, n, acc=[]: f(x[:-n], n, [(x[-n:])]+acc) if x else acc
intpart = thousand_sep.join(f(intstr, 3))
return "%s%s%s%s" % (symbol, intpart, decimal_sep, ("%0.2f" % value)[-2:])
@gsiegman
gsiegman / code
Created November 20, 2012 05:35
Why?
# models
class Track(models.Model):
id = models.IntegerField(primary_key=True)
recording = models.IntegerField()
tracklist = models.ForeignKey(Tracklist, db_column="tracklist", related_name="tracks")
position = models.IntegerField()
name = models.CharField(max_length=255, unique=True)
artist_credit = models.ForeignKey(
ArtistCredit,