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
| input_data = open('data.csv', 'r') | |
| output_data = open('out.csv', 'w') | |
| for line in input_data: | |
| data = line[0:-2] # snip off the new line character and trailing comma | |
| output_data.write( data + '\n' ) # add the newline back | |
| input_data.close() | |
| output_data.close() |
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
| #!/usr/bin/env python | |
| ''' | |
| optparse_testing.py | |
| some recipes from http://www.alexonlinux.com/pythons-optparse-for-human-beings | |
| ''' | |
| import optparse | |
| parser = optparse.OptionParser() | |
| # basics |
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
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import Queue | |
| import threading | |
| import urllib2 | |
| import time | |
| hosts = ['http://yahoo.com', 'http://google.com', 'http://amazon.com', | |
| 'http://ibm.com', 'http://apple.com'] |
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.neotitans.com/resources/python/python-threads-multithreading-tutorial.html | |
| import sys | |
| import time | |
| import random | |
| import threading | |
| def worker(name): | |
| print 'I am %s and starting now' % name | |
| wait = random.randint(2,7) | |
| time.sleep(wait) |
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
| body { | |
| background-image: url(img/striped.jpg); | |
| background-repeat: repeat; | |
| } |
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 werkzeug.contrib.fixers import ProxyFix | |
| from flask_app import * | |
| app.wsgi_app = ProxyFix(app.wsgi_app) |
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
| workers = 2 | |
| bind = '127.0.0.1:8000' | |
| proc_name = 'www.yupyupnope.com' | |
| pidfile = '/tmp/www.yupyupnope.com.pid' |
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
| user www-data; | |
| worker_processes 4; | |
| pid /var/run/nginx.pid; | |
| events { | |
| worker_connections 768; | |
| } | |
| http { | |
| sendfile on; |
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
| server { | |
| listen 80; | |
| server_name www.yupyupnope.com; | |
| rewrite ^/(.*) https://yupyupnope.com/$1 permanent; | |
| } | |
| server { | |
| listen 80; | |
| server_name yupyupnope.com; | |
| rewrite ^/(.*) https://yupyupnope.com/$1 permanent; |
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
| This little 'app' responds in uppercase with whatever url path you specify. | |
| It's the Flask-based alternative of the Django example written up here: http://gun.io/blog/python-for-the-web/ | |
| to make it work, create this directory structure: | |
| uppify/ | |
| | - serve.py | |
| | - templates/ | |
| | - uppify.html |
OlderNewer