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
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| # David Lutz's Multi VM Vagrantfile | |
| # inspired from Mark Barger's https://gist.github.com/2404910 | |
| boxes = [ | |
| { :name => :web, :role => 'web_dev', :ip => '192.168.33.1', :ssh_port => 2201, :http_fwd => 9980, :cpus =>4, :shares => true }, | |
| { :name => :data, :role => 'data_dev', :ip => '192.168.33.2', :ssh_port => 2202, :mysql_fwd => 9936, :cpus =>4 }, | |
| { :name => :railsapp, :role => 'railsapp_dev', :ip => '192.168.33.3', :ssh_port => 2203, :http_fwd => 9990, :cpus =>1} | |
| ] |
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
| print A('bar', href="foo") ==> <A href="foo">bar</A> |
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
| import flask | |
| import gevent | |
| app = flask.Flask(__name__) | |
| def task(): | |
| print flask.render_template_string('Hello World!') | |
| def with_context(): | |
| with flask.current_app.test_request_context(): |
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://stackoverflow.com/questions/2516665/how-can-i-monitor-the-rendering-time-in-a-browser | |
| var renderStart = new Date().getTime(); | |
| window.onload=function() { | |
| var elapsed = new Date().getTime()-renderStart; | |
| // send the info to the server | |
| alert('Rendered in ' + elapsed + 'ms'); | |
| } | |
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
| import functools | |
| import time | |
| def debug(func): | |
| @functools.wraps(func) | |
| def f(self, *args, **kwargs): | |
| start = time.now() | |
| _return = func(self, *args, **kwargs) | |
| diff = time.now() - start | |
| print '%s (%.2fms)' % (func, diff) |
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
| gevent | |
| redis | |
| requests | |
| tornado | |
| tornadoredis |
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
| import flask | |
| app = flask.Flask(__name__) | |
| app.config['SERVER_NAME'] = 'localhost' | |
| @app.route('/') | |
| def index(): return "Index!" | |
| if __name__ == '__main__': | |
| app.run() |
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
| (function() { | |
| var script, | |
| scripts = document.getElementsByTagName('script')[0]; | |
| function load(url) { | |
| script = document.createElement('script'); | |
| script.async = true; | |
| script.src = url; | |
| scripts.parentNode.insertBefore(script, scripts); |
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
| # imgs don't need to be gzipped | |
| s3cmd put -c config/.s3cfg-prod-static --acl-public --guess-mime-type --add-header "Cache-Control:public, max-age=31536000" -r static/img s3://my-bucket-name/ | |
| # js/css does need gzipping | |
| rm -rf static/built-gz; | |
| cp -a static/built/ static/built-gz/; | |
| find static/built-gz -type f | while read -r x; do gzip -9 -c "$x" > "$x.gz"; mv "$x.gz" "$x"; done; | |
| s3cmd put -c config/.s3cfg-prod-static --acl-public --guess-mime-type --add-header "Cache-Control:public, max-age=31536000" --add-header "Content-Encoding: gzip" -r static/built-gz/ s3://my-bucket-name/built/ |
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
| global | |
| log 127.0.0.1 local0 notice | |
| maxconn 50000 | |
| daemon | |
| stats socket /tmp/proxystats level admin | |
| defaults | |
| log global | |
| mode http | |
| option httplog | |
| option dontlognull |
OlderNewer