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
emails = {'Dick': 'bob@example.com', 'Jane': 'jane@example.com', 'Stou': 'stou@example.net'} | |
email_at_dotcom = dict( [name, '.com' in email] for name, email in emails.iteritems() ) | |
# email_at_dotcom now is {'Dick': True, 'Jane': True, 'Stou': False} | |
# ANOTHER OPTION TO CREATE DICTS ON THE FLY: |
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
""" MoinMoin - Python Source Parser """ | |
import cgi, sys, cStringIO | |
import keyword, token, tokenize | |
# Python Source Parser (does highlighting into HTML) | |
_KEYWORD = token.NT_OFFSET + 1 | |
_TEXT = token.NT_OFFSET + 2 | |
_colors = { | |
token.NUMBER: '#0080C0', | |
token.OP: '#0000C0', | |
token.STRING: '#004080', |
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
DROP TABLE IF EXISTS `django_session_cleaned`; | |
CREATE TABLE `django_session_cleaned` ( | |
`session_key` varchar(40) NOT NULL, | |
`session_data` longtext NOT NULL, | |
`expire_date` datetime NOT NULL, | |
PRIMARY KEY (`session_key`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | |
INSERT INTO `django_session_cleaned` SELECT * FROM `django_session` WHERE `expire_date` > CURRENT_TIMESTAMP; |
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
## settings.py | |
TEMPLATE_CONTEXT_PROCESSORS = ( | |
"django.contrib.auth.context_processors.auth", | |
"django.core.context_processors.debug", | |
"django.core.context_processors.i18n", | |
"django.core.context_processors.media", | |
"django.core.context_processors.static", | |
"django.contrib.messages.context_processors.messages", | |
"django.core.context_processors.request", | |
) |
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
# Try to use the C implementation first, falling back to python | |
try: | |
from xml.etree import cElementTree as ElementTree | |
except ImportError, e: | |
from xml.etree import ElementTree | |
########## | |
def find(*args, **kwargs): | |
"""Find a book in the collection specified""" |
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
if (testarray.length <1) alert("array is empty"); | |
//or | |
if(A && A.length==0) | |
//or if you have other objects that A may be: | |
if(A && A.constructor==Array && A.length==0) |
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
mylist = range(150) | |
nestedlist = [mylist[start:start + 20] for start in range(0, len(mylist), 20)] |
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
// For jQuery 1.2 | |
jQuery.extend( | |
jQuery.expr[':'], { | |
Contains : "jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase())>=0" | |
}); | |
// For jQuery 1.3 (thanks @user95227) and later you need |
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
(define-macro (change-list lst) | |
`(set! ,lst (map (lambda (i) (+ i 1)) ,lst))) | |
(define mylist '(1 2 3 4 5)) | |
(change-list mylist) |
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
javascript:location.href="http://delicious.com/url/view?url="%20+%20location.href; |
OlderNewer