Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python2.6
def find_anagrams(input_word):
words = (word[:-1] for word in open('/usr/share/dict/words').readlines())
return [word for word in words if (sorted(word) == sorted(input_word) and word != input_word)]
if __name__ == '__main__':
import sys
print find_anagrams(sys.argv[1])

Deploying Django on HostMonster Shared Hosting

I haven't fully tested this yet, so I may have forgotten a step (or two) but this should be fairly accurate.

  1. Set up SSH access on the host.
  2. Add your SSH to ~/.ssh/authorized_keys on the host.
  3. SSH in to the server.
  4. Set up Git.

wget http://kernel.org/pub/software/scm/git/git-1.7.0.6.tar.gz

#!/usr/bin/env python
import timeit
params = {
'domain': 'example.com',
'host': 'www.example.com:8000'
}
string_test = """\
import string
from copy import copy
from hashlib import md5
from urllib import urlencode
from django import template
from django.conf import settings
register = template.Library()
class GravatarNode(template.Node):
def __init__(self, user, size=None):
import re
from django import template
register = template.Library()
@register.filter
def gist(value):
gist_regex = re.compile(r'http://gist\.github\.com/(?P<hash>[\d]+)/?')
return gist_regex.sub(lambda match: u'<script src="http://gist.github.com/%s.js"></script>' % match.group('hash'), value)
gist.is_safe = True
import csv, urllib2
url = 'http://geocoder.us/service/csv/geocode?zip=65807'
response = urllib2.urlopen(url)
reader = csv.reader(response)
for line in reader:
print line
from django import template
register = template.Library()
class PermissionNode(template.Node):
def __init__(self, user, permission, variable_name, obj=None):
self.user = template.Variable(user)
self.permission = template.Variable(permission)
if obj:
self.obj = template.Variable(obj)
from django.db import models
class CustomQuerySetManager(models.Manager):
use_for_related_fields = True
def __init__(self, queryset, *args, **kwargs):
super(CustomQuerySetManager, self).__init__(*args, **kwargs)
self._queryset = queryset
def get_query_set(self):
tedkaemming@reventon % brew install postgresql postgis gdal ~
==> Downloading ftp://ftp.ossp.org/pkg/lib/uuid/uuid-1.6.2.tar.gz
######################################################################## 100.0%
==> ./configure --disable-debug --without-perl --without-php --without-pgsql --prefix=/usr/local/Cellar/ossp-uuid/1.6.2
==> make
==> make install
/usr/local/Cellar/ossp-uuid/1.6.2: 11 files, 364K, built in 9 seconds
==> Downloading http://ftp2.uk.postgresql.org/sites/ftp.postgresql.org/source/v8.4.4/postgresql-8.4.4.tar.bz2
######################################################################## 100.0%
==> ./configure --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --prefix=/usr/local/Cellar/postgresql/8.4.4 --disable-de
#!/usr/bin/env python
import os
ENVIRONMENT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
activate_file = os.path.join(ENVIRONMENT_ROOT, 'bin', 'activate_this.py')
execfile(activate_file, dict(__file__=activate_file))
admin_file = os.path.join(ENVIRONMENT_ROOT, 'bin', 'django-admin.py')
execfile(admin_file)