Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am benctamas on github.
  • I am benctamas (https://keybase.io/benctamas) on keybase.
  • I have a public key whose fingerprint is 37EF 137D 714E C15C 65DE 7D1B CD04 E5E3 5BF9 1C5C

To claim this, I am signing this object:

import re
# http://atomboy.isa-geek.com/plone/Members/acoil/programing/double-metaphone
from metaphone import dm as double_metaphone
# get the Redis connection
from jellybean.core import redis
import models
# Words which should not be indexed
#!/usr/bin/python
#
# This code sample shows (what I hope to be) the right way to reraise an exception in the
# situation where you have to perform some cleanup before reraising.
#
cleaned_up = False
def raiser():
raise RuntimeError("this should be reported at line 10")
/**
* Basic sample plugin inserting a feincms mediaFile into the CKEditor editing area.
*/
// Register the plugin with the editor.
// http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.plugins.html
CKEDITOR.plugins.add( 'feincms',
{
// The plugin initialization logic goes inside this method.
// http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.pluginDefinition.html#init
@benctamas
benctamas / gist:8661792
Last active January 4, 2016 18:39
"block command until reconnected" py-redis client (using gevent); pipelines work diff. way, it needs more code to support them
import gevent
# import gevent.monkey
# gevent.monkey.patch_all()
import redis
import logging
logger = logging.getLogger("redis")

Zerohub

This is used to have a bunch of ZeroRPC clients and workers talking to each other.

WARNING: this is not compatible with heartbeats and streaming!

Clients connect to the "in" side of the hub.

Workers connect to the "out" side of the hub.

"""
IAM boto examples:
In this example we create a group that provides access
to all EC2 and S3 resources and actions and then add a
user to that group.
"""
import boto
#
# First create a connection to the IAM service
# Ubuntu upstart file at /etc/init/mongodb.conf
pre-start script
mkdir -p /var/lib/mongodb/
mkdir -p /var/log/mongodb/
end script
start on runlevel [2345]
stop on runlevel [06]
@benctamas
benctamas / gist:6898898
Last active December 25, 2015 01:59
generator chain (draft1)
class Block(object):
def __init__(self, name=""):
self.name = name
self.target = None
self._sink = []
def __call__(self, f):
self.f = f
gen = self._gen_loop()
@benctamas
benctamas / proxy_model_queryset.py
Created July 11, 2012 00:18
django - heterogeneous proxy model based queryset
from django.db import models
from django.db.models.query import QuerySet
from django.utils.functional import memoize
_class_mapper_cache = {}
def class_mapper(model):
proxy_for = model._meta.proxy_for_model or model
mapper = dict([ (getattr(m, m.CLASS_MAP_ATTR), m) for m in models.get_models() if issubclass(m, proxy_for) and m != proxy_for])
return mapper