This file contains hidden or 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 SUM(LENGTH(name) - LENGTH(REPLACE(name, ' ', ''))+1) FROM table |
This file contains hidden or 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
/* http://meyerweb.com/eric/tools/css/reset/ */ | |
/* v1.0 | 20080212 */ | |
html, body, div, span, applet, object, iframe, | |
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | |
a, abbr, acronym, address, big, cite, code, | |
del, dfn, em, font, img, ins, kbd, q, s, samp, | |
small, strike, strong, sub, sup, tt, var, | |
b, u, i, center, dl, dt, dd, ol, ul, li, | |
fieldset, form, label, legend, | |
table, caption, tbody, tfoot, thead, tr, th, td { |
This file contains hidden or 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
IP_ADDR=`ifconfig | awk '/192/ { print $2 }'` | |
alias l='ls -l' | |
alias ll='ls -la' | |
alias runserver='python manage.py runserver $IP_ADDR:8000' | |
alias runserver80='sudo python manage.py runserver 127.0.0.1:80' | |
alias syncdb='python manage.py syncdb' | |
alias synergys='~/bin/synergy/synergys -f -c ~/bin/synergy/synergy.conf' | |
alias fink='/sw/bin/fink' | |
alias rabbitmq-server='sudo /opt/local/lib/erlang/lib/rabbitmq_server-1.6.0/sbin/rabbitmq-server' |
This file contains hidden or 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 django.core.cache.backends import memcached | |
from django.utils.encoding import smart_str | |
""" | |
Simple Django cache backend overrides for dealing with python-memcached | |
differences between cmemcache. | |
For Django 1.2. All methods except `set_many` and `delete_many` will work for Django 1.1 | |
Use by pointing to it in settings, for example: |
This file contains hidden or 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
<!--[if lte IE 6]> | |
<style type="text/css"> | |
img, div, input, a { behavior: url("http://example.com/path/to/iepngfix.htc") } | |
</style> | |
<![endif]--> |
This file contains hidden or 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 | |
def convert_1252_codes(text): | |
"""Convert windows-1252 characters to appropriate html entities. | |
@param str String to filter | |
@type string/unicode | |
@return unicode version of filtered string | |
Adapted from: http://effbot.org/zone/unicode-gremlins.htm |
This file contains hidden or 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
"""Examples of how to implement inheritance with Django models. | |
Idea here is DRY (don't repeat yourself). If models are similar, let them | |
share functionality to the extent that its ancestrty makes sense. | |
It's important to note is that because of the "abstract = True", Django knows | |
not to create tables for those models, and instead only creates tables for | |
those models that implement those abstract base classes. | |
It can also be noted that instead of having one gigantic, monolithic models.py |
This file contains hidden or 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 random | |
from django.db import models | |
from django.core.cache import cache | |
class CacheManager(models.Manager): | |
'''Generic Cache Manager based on the concept of generator ids to | |
handle invalidation of collections. | |
''' | |
def _test_model(self, obj): |
This file contains hidden or 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
/* http://www.newthink.net */ | |
color: #2a2a2a; | |
text-shadow: rgba(0, 0, 0, 0.113281) 2px 2px 0px; | |
/* http://ozmm.org */ | |
color: red; | |
text-shadow: #0c0c0c 2px 2px 1px; | |
/* http://peroty.tumblr.com */ | |
color: #f2e3c6; |
This file contains hidden or 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
'#' + (~~(Math.random() * 16777215)).toString(16); |