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
// Just before switching jobs: | |
// Add one of these. | |
// Preferably into the same commit where you do a large merge. | |
// | |
// This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
// and then it quickly escalated into more and more evil suggestions. | |
// I've tried to capture interesting suggestions here. | |
// | |
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
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
.git | |
.idea | |
*.pyc | |
__pycache__ | |
local_settings.py | |
db.sqlite3 |
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
# ############################################## | |
# HEROKU DEPLOYMENT | |
# ############################################## | |
# Parse database configuration from $DATABASE_URL | |
import dj_database_url | |
DATABASES['default'] = dj_database_url.config() | |
# Honor the 'X-Forwarded-Proto' header for request.is_secure() | |
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') |
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
''' | |
Simple usage as cherrypy daemon as example | |
''' | |
import soaplib | |
from soaplib.core.server import wsgi | |
from cherrypy.wsgiserver import CherryPyWSGIServer | |
HOST = "0.0.0.0" | |
PORT = 45124 |
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
<div id="disqus_thread"></div> | |
<script type="text/javascript"> | |
/* * * CONFIGURATION VARIABLES * * */ | |
var disqus_shortname = '<your app name>'; | |
/* * * DON'T EDIT BELOW THIS LINE * * */ | |
(function() { | |
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; | |
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; | |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); |
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
// ### PHP / Symfony2 / ORM ###/ | |
// create new document | |
$product = new Product(); | |
$product->setName('A Foo Bar'); | |
$product->setPrice('19.99'); | |
$product->setDescription('Lorem ipsum dolor'); | |
$em = $this->getDoctrine()->getManager(); |
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 hmac | |
import simplejson as json | |
from base64 import urlsafe_b64decode | |
from hashlib import sha256 | |
def parse_signed_request(signed_request, secret): | |
[encoded_sig, payload] = signed_request.split('.') | |
# decode data |
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
""" | |
Python Singleton with parameters (so the same parameters get you the same object) | |
with support to default arguments and passing arguments as kwargs (but no support for pure kwargs). | |
And implementation for MongoClient class from pymongo package. | |
""" | |
from pymongo import MongoClient | |
import inspect | |
OlderNewer