Skip to content

Instantly share code, notes, and snippets.

@zyegfryed
zyegfryed / gist:814432
Created February 7, 2011 14:25
Tastypie OAuth
from oauth2 import Error
from django.utils.translation import ugettext as _
from tastypie.authentication import Authentication
from oauth_provider.utils import initialize_server_request, send_oauth_error, get_oauth_request
from oauth_provider.consts import OAUTH_PARAMETERS_NAMES
from oauth_provider.store import store, InvalidTokenError
@JoshTGreenwood
JoshTGreenwood / gist:443253f42fb80455792f
Created December 1, 2015 22:20
Automatically add magit cloned repos to the projectile project list
(defun add-project-to-projectile-known-projects (_ directory)
(projectile-add-known-project directory))
(advice-add 'magit-clone :after 'add-project-to-projectile-known-projects)
@wichert
wichert / form-example.html
Created November 30, 2012 09:55
WTForms and pyramid integration
<form id="loginForm" method="post" action="${request.route_url('login')}">
<input type="hidden" name="csrf_token" value="${request.session.get_csrf_token()}"/>
<fieldset class="concise">
<metal:field tal:define="name 'came_from'" use-macro="snippets['hidden']"/>
<metal:field tal:define="name 'login'" use-macro="snippets['text']"/>
<metal:field tal:define="name 'password'" use-macro="snippets['password']"/>
</fieldset>
<div class="buttonBar">
<button type="submit" class="default" i18n:translate="">Login</button>
</div>
@dewski
dewski / locally.sh
Created January 20, 2012 16:58 — forked from jasonroelofs/setup-statsd.sh
Turn an EC2 micro instance into a StatsD/Graphite server
ec2-authorize default -p 2003
@wolever
wolever / test_tsquery_escape.py
Last active October 3, 2022 09:47
Parse and escape a query string so it's safe to use with Postgres' `to_tsquery(…)`
import re
from nose.tools import assert_equal
from nose_parameterized import parameterized
from tsquery_escape import tsquery_escape
@parameterized([
("1 OR 2", "1 | 2"),
("(1) 2", "( 1 ) & 2"),
("&", "'&':*"),
@danmackinlay
danmackinlay / supervisord.sh
Created August 27, 2009 07:07
an init.d script for supervisord
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@kylefritz
kylefritz / publishAmazonSnsMsg.py
Created October 18, 2010 22:06
publish a message to Amazon SNS using python or ruby
from time import strftime,gmtime,time
import urllib2
import hmac
import hashlib
import base64
import string
def publishAmazonSnsMsg(Subject,TopicArn,Message,AWSAccessKeyId,privatekey):
#http://docs.amazonwebservices.com/AWSSimpleQueueService/2008-01-01/SQSDeveloperGuide/
amzsnshost = 'sns.us-east-1.amazonaws.com'