Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am xlevus on github.
  • I am xlevus (https://keybase.io/xlevus) on keybase.
  • I have a public key whose fingerprint is AC80 2AE8 6B78 83D3 1008 1348 F3D4 450A 1497 78BF

To claim this, I am signing this object:

@xlevus
xlevus / gist:3899936
Created October 16, 2012 15:22
Guess what this does
def func(lines):
first_pass = list()
#now clean any preceding whitespace
for index, line in enumerate(lines):
table = string.maketrans(string.whitespace, ' ' * len(string.whitespace))
first_pass.append(string.translate(line, table))
clean = list()
for line in first_pass:
@xlevus
xlevus / smart_django_settings.py
Created October 29, 2010 11:27
Relative settings for django.
import os
# project/
# code/
# django/ -> ../dist/django/django
# project/
# html/
# templates/
# media/
# admin/ -> ../../dist/django/django/contrib/admin/media
>>> from django import VERSION
>>> VERSION
(1, 1, 1, 'final', 0)
>>> import memcache
>>> memcache.__version__
'1.31'
>>>
>>> from django.core.cache import cache
>>> cache.set('test_key', u'\u2026')
>>> cache.get('test_key')
import random
import urllib2
from BeautifulSoup import BeautifulSoup
req = urllib2.urlopen('http://c2.com/cgi/wiki?AntiPatternsCatalog')
soup = BeautifulSoup(req.read())
lists = list(soup.findAll("li"))