Note: Prefer Exim4 over Sendmail
Append the following directives into /etc/mail/sendmail.mc.
These lines should come before mailer definitions.
define(`SMART_HOST',`mail.example.com')
define(`RELAY_MAILER_ARGS', `TCP $h 587')
| import json | |
| import geojson | |
| from shapely.geometry import shape | |
| o = { | |
| "coordinates": [[[23.314208, 37.768469], [24.039306, 37.768469], [24.039306, 38.214372], [23.314208, 38.214372], [23.314208, 37.768469]]], | |
| "type": "Polygon" | |
| } | |
| s = json.dumps(o) |
| import json | |
| import datetime | |
| '''Create an encoder subclassing JSON.encoder. | |
| Make this encoder aware of our classes (e.g. datetime.datetime objects) | |
| ''' | |
| class Encoder(json.JSONEncoder): | |
| def default(self, obj): | |
| if isinstance(obj, datetime): | |
| return obj.isoformat() |
| import logging, logging.config | |
| import os | |
| here = os.path.dirname(os.path.realpath(__file__)) | |
| ini_file = os.path.join(here, 'development.ini') | |
| # Activate enviroment | |
| activate_this = os.path.realpath(os.path.join(here, '../..', 'bin/activate_this.py')) | |
| execfile(activate_this, dict(__file__=activate_this)) |
| import java.io.InputStreamReader; | |
| import java.io.Reader; | |
| import java.io.BufferedReader; | |
| import java.io.InputStream; | |
| import java.net.URL; | |
| import java.net.URLConnection; | |
| import javax.net.ssl.HostnameVerifier; | |
| import javax.net.ssl.HttpsURLConnection; | |
| import javax.net.ssl.SSLContext; |
| import logging | |
| pairs = [] | |
| def baz_decorator(target_cls): | |
| def decorate(cls): | |
| logging.info('Decorating class %s with target %s' %(cls, target_cls)) | |
| pairs.append((cls, target_cls)) | |
| return cls | |
| return decorate |
| #!/bin/bash | |
| # | |
| # Example using getopt (vs builtin getopts) that can also handle long options. | |
| # Another clean example can be found at: | |
| # http://www.bahmanm.com/blogs/command-line-options-how-to-parse-in-bash-using-getopt | |
| # | |
| aflag=n | |
| bflag=n |
| class Foo(object): | |
| def __init__(self, x): | |
| self._x = x | |
| def __format__(self, format_spec): | |
| return '<Foo x={0}>'.format(self._x) | |
| foo = Foo(12) |
| _cache = dict() | |
| def memoize(fn): | |
| print 'Creating wrapper for %r ...' %(fn) | |
| cached_results = _cache[fn] = dict() | |
| def wrap(*args): | |
| cid = args | |
| if cid in cached_results: | |
| res = cached_results[cid] | |
| else: |
| # Demonstate super() on a simple-inheritance scenario | |
| class A(object): | |
| def __init__(self, x): | |
| self.x = x | |
| def foo(self, y): | |
| print 'A.foo(%r) on instance %r' %(y, self) | |