Skip to content

Instantly share code, notes, and snippets.

@JoshTGreenwood
JoshTGreenwood / gist:443253f42fb80455792f
Created Dec 1, 2015
Automatically add magit cloned repos to the projectile project list
View gist:443253f42fb80455792f
(defun add-project-to-projectile-known-projects (_ directory)
(projectile-add-known-project directory))
(advice-add 'magit-clone :after 'add-project-to-projectile-known-projects)
@wolever
wolever / test_tsquery_escape.py
Last active Apr 6, 2021
Parse and escape a query string so it's safe to use with Postgres' `to_tsquery(…)`
View test_tsquery_escape.py
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"),
("&", "'&':*"),
@wichert
wichert / form-example.html
Created Nov 30, 2012
WTForms and pyramid integration
View form-example.html
<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 Jan 20, 2012 — forked from jasonroelofs/setup-statsd.sh
Turn an EC2 micro instance into a StatsD/Graphite server
View locally.sh
ec2-authorize default -p 2003
View gist:814432
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
@kylefritz
kylefritz / publishAmazonSnsMsg.py
Created Oct 18, 2010
publish a message to Amazon SNS using python or ruby
View publishAmazonSnsMsg.py
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'
@danmackinlay
danmackinlay / supervisord.sh
Created Aug 27, 2009
an init.d script for supervisord
View supervisord.sh
#! /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.