Skip to content

Instantly share code, notes, and snippets.

(╯°□°)╯︵ ┻━┻

David Larlet davidbgk

(╯°□°)╯︵ ┻━┻
View GitHub Profile
davidbgk /
Created Apr 28, 2010
Django: Current Page Middleware
Current Page Middleware.
This module provides a middleware that implements a mechanism to
highlight a link pointing to the current URL.
Thanks @davidbgk and @samueladam for improvements & optimizations
import re
davidbgk / classinstancemethod
Created Apr 30, 2010 — forked from ianb/Lightning talk
when you want to use both a classmethod and the function with a class instance
View classinstancemethod
# classinstancemethod, when you want to use both a classmethod and the function with a class instance
## Descriptors
## Anything with __get__ and optionally __set__:
class classinstancemethod(object):
def __init__(self, func):
self.func = func
def __get__(self, obj, type=None):
davidbgk / gist:805600
Created Feb 1, 2011 — forked from adamcharnock/gist:389875
Double metaphone
View gist:805600
import re
from metaphone import dm as double_metaphone
# get the Redis connection
from jellybean.core import redis
import models
# Words which should not be indexed
davidbgk /
Created Jul 26, 2011 — forked from jsocol/
Give an image, get a data-uri
#!/usr/bin/env python
"""Command line script to convert a file, usually an image, into a data URI
for use on the web."""
import base64
import mimetypes
import os
import sys
davidbgk / field.html
Created Nov 9, 2011 — forked from pydanny/field.html
django-uni-form + Twitter Bootstrap
View field.html
<!-- this usually goes in <project-root>/templates/uni_form/field.html -->
{% if field.is_hidden %}
{{ field }}
{% else %}
<div class="clearfix {% if field.errors %}error{% endif %}">
<label for="{{ field.auto_id }}" {% if field.field.required %}class="requiredField"{% endif %}>
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
<div class="input">
davidbgk / gist:2495085
Created Apr 26, 2012 — forked from paulirish/gist:839879
requestAnimFrame() shim.
View gist:2495085
// see
// shim layer with setTimeout fallback
window.requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
davidbgk /
Created May 11, 2012 — forked from asenchi/
maximum battery life checklist -- use before a long plane flight

Max Battery Life Checklist

Here is a checklist to follow if you want maximum battery life -- for instance if you're about to get on a long plane flight.

10 hour battery life on a non-SSD Macbook Pro 17"

Low power use checklist

With power connected:

davidbgk / postsql.sql
Created May 17, 2012 — forked from tobyhede/postsql.sql
PostgreSQL as JSON Document Store
View postsql.sql
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8
-- JSON Types need to be mapped into corresponding PG types
-- String => TEXT
davidbgk /
Created Jun 11, 2012 — forked from kennethreitz42/
My typical flask app base
# -*- coding: utf-8 -*-
import os
from flask import Flask
from flask_heroku import Heroku
from flask_sslify import SSLify
from raven.contrib.flask import Sentry
from flask.ext.celery import Celery
davidbgk /
Created Jun 24, 2012 — forked from jordansissel/
Logstash 1.1.1 + ElasticSearch 0.19.5 compression tests

compression tests of logstash+elasticsearch

  • logstash 1.1.1-pre (unreleased)
  • elasticsearch 0.19.5-SNAPSHOT (unreleased)
You can’t perform that action at this time.