Latest 100 public snipts »
Fotinakis's
snipts » python
showing 1-4 of 4 snipts for python
-
∞ Disassembler for Python bytecode
$ python -m dis test.py 1 0 LOAD_CONST 0 ('Hello world') 3 PRINT_ITEM 4 PRINT_NEWLINE 5 LOAD_CONST 1 (None) 8 RETURN_VALUE
-
∞ Simple generation of random string in Python
import string import random print "".join(random.sample(string.letters+string.digits, 8))
-
∞ Django mod-wsgi hook file
import os, sys import django.core.handlers.wsgi path = '/var/www/sub.example.com' if path not in sys.path: sys.path.append(path) os.environ['DJANGO_SETTINGS_MODULE'] = 'project_name.settings' application = django.core.handlers.wsgi.WSGIHandler()
-
∞ Mass dynamic Django hosting based on hostname
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/root RewriteEngine On RewriteMap tolower int:tolower # Redirect all www. RewriteCond %{HTTP_HOST} ^www\..*$ RewriteRule ^(.+) %{HTTP_HOST}$1 [C] RewriteRule ^www\.(.*) http://$1 [R=301,L] # For all admin media RewriteRule ^/media(.*) /usr/share/python-support/python-django/django/contrib/admin/media$1 [L] # For each project's static files RewriteRule ^/static(.*) /var/www/${tolower:%{SERVER_NAME}}/static$1 RewriteRule ^/favicon.ico /var/www/${tolower:%{SERVER_NAME}}/static/images/favicon.ico # For each project's documentation RewriteRule ^/docs(.*) /var/www/${tolower:%{SERVER_NAME}}/docs/build/html$1 # For each project's WSGI hook RewriteRule ^/(?!var/www/)(.*) /var/www/${tolower:%{SERVER_NAME}}/apache/django.wsgi/$1 RewriteRule . - [E=APPLICATION_GROUP:${tolower:%{SERVER_NAME}}] WSGIProcessGroup %{GLOBAL} WSGIApplicationGroup %{ENV:APPLICATION_GROUP} # Run mod_wsgi in daemon mode, with daemons named by the site name WSGIDaemonProcess %{ENV:APPLICATION_GROUP} processes=5 threads=10 python-path=/path/to/common display-name=%{GROUP} <Directory /var/www/*/apache> Order allow,deny Allow from all Options ExecCGI AddHandler wsgi-script .wsgi </Directory> <Directory /var/www/*/docs> # You can protect the docs directories here </Directory> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined </VirtualHost>


