Skip to content

Instantly share code, notes, and snippets.

View wichert's full-sized avatar

Wichert Akkerman wichert

View GitHub Profile

Keybase proof

I hereby claim:

  • I am wichert on github.
  • I am wichert (https://keybase.io/wichert) on keybase.
  • I have a public key whose fingerprint is 5D61 B9A0 8594 F6FA 57AB 2EA2 8A93 CA33 1E53 1D8B

To claim this, I am signing this object:

@wichert
wichert / queue.py
Created April 15, 2014 08:45
Example of integration rq with transactions
def enqueue(request, queue, func, *a, **kw):
"""Queue a function call.
:param request: Pyramid request object
:param queue: name of the rq queue to use
:param func: function or instance method to call
:return: rq job instance
>>> enqueue(request, 'email', myfunc, arg1, arg2)
"""
@wichert
wichert / pqxx.cc
Last active December 17, 2015 16:09
Minimal uuid and HSTORE support for pqxx
#include <boost/algorithm/string/join.hpp>
#include <boost/format.hpp>
#include <boost/regex.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <stylist/private/pqxx.hh>
using namespace std;
@wichert
wichert / uuid.cc
Last active December 17, 2015 03:28
boost::uuids::uuid convertor for boost::python
#include <string>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/nil_generator.hpp>
#include <boost/uuid/string_generator.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/python.hpp>
namespace python = boost::python;
@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>
@wichert
wichert / convert.py
Created November 5, 2012 12:37
Patternslib syntax converter
import argparse
import os
import re
import sys
from lxml import etree
def read(fn):
with open(fn, 'r') as input:
parser = etree.HTMLParser()
@wichert
wichert / gist:3426993
Created August 22, 2012 15:58
errormator javascript logging experiment
<!DOCTYPE html>
<html>
<head>
<title>Javascript error handling logic</title>
</head>
<body>
<script type="text/javascript" src="https://github.com/downloads/eriwen/javascript-stacktrace/stacktrace-0.4.js"></script>
<script type="text/javascript">
// <![CDATA[
// ]]>
@wichert
wichert / gist:1244896
Created September 27, 2011 12:02
Accept-Language aware locale negotiator for Pyramid
#: Mapping of language codes send by browsers to supported dialects.
BROWSER_LANGUAGES = {
'en-CA': 'en_CA',
'en-GB': 'en_GB',
'en-US': 'en_GB',
'en': 'en_GB',
'nl': 'nl_NL',
'nl-NL': 'nl_NL',
'nl-BE': 'nl_NL',
'zh': 'zh_CN',
@wichert
wichert / test_tmpstore.py
Last active September 26, 2015 14:17
redis deform.interfaces.FileUploadTempStore implementation
import unittest
import pyramid.testing
class RedisTempStoreTests(unittest.TestCase):
def setUp(self):
from .tmpstore import DummyRedis
self.config = pyramid.testing.setUp()
self.config.registry.settings['redis'] = self.redis = DummyRedis()
@wichert
wichert / gist:1082147
Created July 14, 2011 09:15
Chameleon XI/Metal combination trick
<!-- tools.pt -->
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
xmlns:meta="http://xml.zope.org/namespaces/meta"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal"
meta:interpolation="true"
tal:condition="False">
<metal:tooltip define-macro="tooltip">