Skip to content

Instantly share code, notes, and snippets.

@atiw003
atiw003 / postfix-config-aws-ses.txt
Created June 9, 2012 11:53 — forked from zapnap/postfix-config-aws-ses.txt
postfix config for AWS-SES
# /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
@atiw003
atiw003 / fabfile.py
Created June 9, 2012 13:21 — forked from cyberdelia/fabfile.py
Fabric deploy script with : south migrations, rollback and maintenance page.
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 }
@atiw003
atiw003 / gunicorn vs bjoern
Created June 24, 2012 12:51 — forked from yashh/gunicorn vs bjoern
Benchmark a flask hello world app
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
@atiw003
atiw003 / gist:2999087
Created June 26, 2012 21:14 — forked from msluyter/gist:1925069
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@atiw003
atiw003 / gist:2999089
Created June 26, 2012 21:14 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@atiw003
atiw003 / gist:3008778
Created June 28, 2012 03:34 — forked from lqez/gist:1520810
An alternative approach to drop all tables in django project
#!/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'] )
@atiw003
atiw003 / django.vcl
Created June 30, 2012 23:42 — forked from 10p-freddo/django.vcl
Django VCL for Varnish
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") {
@atiw003
atiw003 / gist:3029700
Created July 1, 2012 21:27 — forked from sadache/gist:3026886
Bits'bout Play2 Architecture

Play2 Simple HTTP API

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 
@atiw003
atiw003 / s3clonebucket.py
Created July 21, 2012 23:39 — forked from erans/s3clonebucket.py
Clone S3 Bucket
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:
@atiw003
atiw003 / README.md
Created August 2, 2012 22:46 — forked from baldurthoremilsson/README.md
File hash GET parameters for Django staticfiles

About

A class for the static files app in Django that invalidates outdated browser cache.

How to use

You add the line

STATICFILES_STORAGE = 'path.to.hashpathstaticfilesstorage.HashPathStaticFilesStorage'