Skip to content

Instantly share code, notes, and snippets.

View llonchj's full-sized avatar

Jordi Llonch llonchj

  • Victoria / Australia
View GitHub Profile
class RedisSessionStore(SessionStore):
def __init__(self, expire = 1800, key_prefix=''):
SessionStore.__init__(self)
self.redis = redis.Redis(tools.config.get('redis_host', 'localhost'),
int(tools.config.get('redis_port', 6379)),
int(tools.config.get('redis_dbindex', 1)),
password=tools.config.get('redis_pass', None))
self.path = session_path()
self.expire = expire
self.key_prefix = key_prefix
@benwah
benwah / mongo_serialize.py
Created June 28, 2012 04:43
Queryset / List of queryset serializer for mongoengine models.
import json
import datetime
from decimal import Decimal
from mongoengine.queryset import queryset_manager
from mongoengine.queryset import QuerySet
from mongoengine.base import BaseList, BaseDict, ObjectId
def list_encoder(inst, obj, field, force_string=False):
"""
@gregoryp
gregoryp / elasticsearch_cache
Created March 29, 2012 10:27 — forked from rafl/elasticsearch_cache
Munin ElasticSearch plugins
#!/usr/bin/env perl
# Parameters supported:
#
# config
# autoconf
#
# Magic markers:
#%# family=auto
#%# capabilities=autoconf
@mkyed
mkyed / gist:1694240
Created January 28, 2012 13:05
Installing PowerDNS 3.0.1 on Mac OS X Lion
1) Install MySQL <http://dev.mysql.com/>
2) Install Homebrew <http://mxcl.github.com/homebrew/>
3) $ brew install boost boost-jam lua pkg-config wget
4) $ wget http://downloads.powerdns.com/releases/pdns-3.0.1.tar.gz && tar xzf pdns-3.0.1.tar.gz
5) $ cd pdns-3.0.1 && ./configure --with-mysql-includes=/usr/local/mysql/include && make && make install
6) Adjust /usr/local/etc/pdns.conf to your mysql setup
7) cat /System/Library/LaunchDaemons/pdns_server.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@HenrikJoreteg
HenrikJoreteg / JS Util solution using underscore.js
Created October 22, 2010 21:20
Rather than creating some other util global, just extend underscore.js with any additional methods you want.
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/)
// Then, use underscore's mixin method to extend it with all your other utility methods
// like so:
_.mixin({
escapeHtml: function () {
return this.replace(/&/g,'&amp;')
.replace(/>/g,'&gt;')
.replace(/</g,'&lt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;');