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
| def auto_version(endpoint, **values): | |
| """ | |
| Auto versions static assets. | |
| """ | |
| from flask import current_app as app | |
| from flask import url_for | |
| if app.debug: | |
| return url_for(endpoint, **values) | |
| # Check if accessing static file. | |
| static_root = None |
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
| def _simple_processor(processor, ext_private, ext_public): | |
| if not request.path.endswith(ext_public): | |
| return | |
| public_file = request.path[len(config.app.static_url_path) + 1:] | |
| public_file_path = os.path.join(config.app.static_folder, public_file) | |
| private_file_path = public_file_path[:-len(ext_public)] + ext_private | |
| # File does not exist in app static - check blueprints. | |
| if not os.path.isfile(private_file_path): | |
| for blueprint_name, blueprint in config.app.blueprints.iteritems(): | |
| if request.path.startswith(blueprint.static_url_path): |
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
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns | |
| Compress 1K bytes with Zippy 3,000 ns | |
| Send 2K bytes over 1 Gbps network 20,000 ns | |
| Read 1 MB sequentially from memory 250,000 ns | |
| Round trip within same datacenter 500,000 ns | |
| Disk seek 10,000,000 ns |
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
| (defn fact-iter [product counter max-count] | |
| (if (> counter max-count) | |
| product | |
| (recur (* counter product) (inc counter) max-count))) | |
| (defn factorial [n] | |
| (fact-iter 1 1 n)) |
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 | |
| from flask import Flask, request | |
| app = Flask(__name__) | |
| app.debug = True | |
| fnids = {} | |
| idx = 0 | |
| def store_fnid(fn): | |
| global idx |
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
| ± $ python streaming.py | |
| Traceback (most recent call last): | |
| File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 438, in handle_one_response | |
| self.run_application() | |
| File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 425, in run_application | |
| self.process_result() | |
| File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 416, in process_result | |
| self.write(data) | |
| File "/usr/local/lib/python2.7/dist-packages/gevent/pywsgi.py", line 368, in write | |
| towrite.append("%x\r\n%s\r\n" % (len(data), data)) |
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 | |
| import gevent | |
| from gevent.pywsgi import WSGIServer | |
| from gevent import monkey | |
| monkey.patch_all() | |
| from flask import Flask, Response | |
| app = Flask(__name__) |
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 | |
| import gevent | |
| from gevent.pywsgi import WSGIServer | |
| from gevent import monkey | |
| monkey.patch_all() | |
| from flask import Flask, Response | |
| app = Flask(__name__) |
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 root; | |
| worker_processes 4; | |
| # [ debug | info | notice | warn | error | crit ] | |
| events { | |
| worker_connections 1024; | |
| } | |
| http { |
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
| # remap prefix to C-a | |
| unbind C-b | |
| set -g prefix C-a | |
| bind a send-prefix | |
| # force a reload of the config files. | |
| unbind r | |
| bind r source-file ~/.tmux.conf | |
| # Screen like bindings. |