IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » Fotinakis's snipts » python The latest python snipts from Fotinakis.

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        
    

    copy | embed

    0 comments - tagged in  posted by Fotinakis on Jul 14, 2009 at 1:50 a.m. EDT
  • Simple generation of random string in Python
    import string
    import random
    
    print "".join(random.sample(string.letters+string.digits, 8))
    

    copy | embed

    0 comments - tagged in  posted by Fotinakis on Jun 18, 2009 at 1:14 p.m. EDT
  • 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()
    

    copy | embed

    0 comments - tagged in  posted by Fotinakis on Apr 22, 2009 at 3:36 p.m. EDT
  • 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>
    

    copy | embed

    0 comments - tagged in  posted by Fotinakis on Apr 22, 2009 at 3:31 p.m. EDT
Sign up to create your own snipts, or login.