Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.
| Ctrl+C | copy current line (if no selection) |
| Ctrl+X | cut current line (if no selection) |
| Ctrl+⇧+K | delete line |
| Ctrl+↩ | insert line after |
| # /etc/postfix/main.cf | |
| smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu) | |
| biff = no | |
| append_dot_mydomain = no | |
| readme_directory = no | |
| # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for |
| from fabric.api import env, run, sudo, local, put | |
| def production(): | |
| """Defines production environment""" | |
| env.user = "deploy" | |
| env.hosts = ['example.com',] | |
| env.base_dir = "/var/www" | |
| env.app_name = "app" | |
| env.domain_name = "app.example.com" | |
| env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name } |
| apt-get install python-setuptools python-pip | |
| pip install Flask gunicorn | |
| ab -n 5000 -c 50 http://ec2-50-16-28-212.compute-1.amazonaws.com/ | |
| worker = 1 | |
| Concurrency Level: 50 | |
| Time taken for tests: 53.365 seconds |
Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.
| Ctrl+C | copy current line (if no selection) |
| Ctrl+X | cut current line (if no selection) |
| Ctrl+⇧+K | delete line |
| Ctrl+↩ | insert line after |
| #!/usr/bin/python | |
| # Alternative approach. | |
| import os | |
| import MySQLdb | |
| print 'drop remaining tables...' | |
| for name, db in settings.DATABASES.iteritems(): | |
| conn = MySQLdb.connect( db['HOST'], db['USER'], db['PASSWORD'], db['NAME'] ) |
| sub vcl_recv { | |
| # unless sessionid/csrftoken is in the request, don't pass ANY cookies (referral_source, utm, etc) | |
| if (req.request == "GET" && (req.url ~ "^/static" || (req.http.cookie !~ "sessionid" && req.http.cookie !~ "csrftoken"))) { | |
| remove req.http.Cookie; | |
| } | |
| # normalize accept-encoding to account for different browsers | |
| # see: https://www.varnish-cache.org/trac/wiki/VCLExampleNormalizeAcceptEncoding | |
| if (req.http.Accept-Encoding) { | |
| if (req.http.Accept-Encoding ~ "gzip") { |
Essential blueprint of Play2 architecture is pretty simple and it should be easy to explain in a fairly short blog post. The framework can be understood progressively at different levels; each time having better exposure to some aspects of its design.
The core of Play2 is really small, surrounded by a fair amount of useful APIs, services and structure to make Web Programming tasks easier.
Basically, Play2 is an API that abstractly have the folllowing type
RequestHeader -> Array[Byte] -> Result | import argparse | |
| from boto.s3.connection import S3Connection | |
| from boto.exception import S3ResponseError | |
| def run(args): | |
| s3_connection = S3Connection(args.aws_access_key, args.aws_secret_access_key) | |
| source_bucket = s3_connection.get_bucket(args.source_bucket) | |
| destination_bucket = None | |
| try: |