Skip to content

Instantly share code, notes, and snippets.

@aj-justo
aj-justo / gist:3228782
Created August 1, 2012 17:02
SSL setup with Nginx + Gunicorn + Django 1.3 or 1.4

Configuring Nginx to serve SSL content is straight forward, once you have your certificate and key ready: server {    listen 443 default ssl;    root /path/to/source;    server_name mydomain;

   ssl_certificate      /path/to/cert;    ssl_certificate_key  /path/to/key;

@gipi
gipi / 000.mkd
Last active March 22, 2021 18:41
#postfix #dovecot #sasl #roundcube #postgresql

Configure reverse DNS in order to avoid mail seen as spam. From command line you can check as follow

$ nslookup ktln2.org
Server:		127.0.0.1
Address:	127.0.0.1#53

Non-authoritative answer:
Name:	ktln2.org
Address: 46.102.247.82
@rochacbruno
rochacbruno / haversine.py
Created June 6, 2012 17:43
Calculate distance between latitude longitude pairs with Python
#!/usr/bin/env python
# Haversine formula example in Python
# Author: Wayne Dyck
import math
def distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
@wrunk
wrunk / jinja2_file_less.py
Last active September 19, 2023 15:05
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@bortzmeyer
bortzmeyer / gist:1284249
Created October 13, 2011 13:42
The only simple way to do SSH in Python today is to use subprocess + OpenSSH...
#!/usr/bin/python
# All SSH libraries for Python are junk (2011-10-13).
# Too low-level (libssh2), too buggy (paramiko), too complicated
# (both), too poor in features (no use of the agent, for instance)
# Here is the right solution today:
import subprocess
import sys
@fohlin
fohlin / forms.py
Created January 8, 2011 18:50
A version of Django's UserCreationForm that uses email instead of username, with some nifty features. (Maybe not super robust yet, in terms of concurrency...)
import re
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class UniqueUserEmailField(forms.EmailField):
"""
An EmailField which only is valid if no User has that email.
"""
def validate(self, value):