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
import sys | |
import time | |
import math | |
import optparse | |
__version__ = "0.1" | |
__copyright__ = "CopyRight (C) 2013 by Michele Pasin" | |
__license__ = "MIT" |
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
# in your project.wsgi file | |
import os, sys | |
#add the desired django version at the beginning of the path; mind you must provide the Django folder as downloaded! | |
sys.path.insert(1, "/path/to/Django/") | |
sys.path.append('/my/project/root/') # add things as usual... | |
# the rest is the normal wsgi stuff... |
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
mysql> ALTER TABLE Employee ADD (EMail VARCHAR(25), ICQ VARCHAR(15)); |
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
import os, random | |
random.choice(os.listdir("C:\\")) #change dir name to whatever |
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
# --- catch: | |
try: | |
generateSomeException() | |
except Exception, e: # Mother of all exceptions | |
print e | |
# --- throw: | |
try: |
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) |
OlderNewer