Skip to content

Instantly share code, notes, and snippets.

commit 32f8d2ec532aaacfc82e85be49f01b89c847ed23
Author: Kyle Ambroff <kambroff@jawbone.com>
Date: Wed Jan 16 22:53:01 2013 -0800
Fix leak of list objects and two instances where facts are leaked.
diff --git a/clipsmodule.c b/clipsmodule.c
index 2275921..5c0d81d 100644
--- a/clipsmodule.c
+++ b/clipsmodule.c
@ambroff
ambroff / bench.py
Created June 30, 2012 06:32
comparing JSON and Thrift serialization speed / data size
import jsonlib
import random
import timeit
import lz4
from thrift.protocol.TBinaryProtocol import TBinaryProtocol
from thrift.protocol.TCompactProtocol import TCompactProtocol
from thrift.transport.TTransport import TMemoryBuffer
deserialization:
cjson 4452.79482ms
jsonlib 4962.96942ms
yajl 4981.6051ms
jsonlib2 5104.00286ms
simplejson 5538.96458ms
json 8193.25433ms
serialization:
jsonlib 2136.25395ms
@ambroff
ambroff / gist:1509153
Created December 22, 2011 06:05
Collapsing a redis cluster from 6 nodes into 2.
1.) [1] [2] [3] Six node cluster
[4] [5] [6]
2.) [1] [2] <= [3] Hosts 2 and 5 replicate from 3 and 6 respectively.
[4] [5] <= [6] Once caught up, the clients are updated to point
to 2 and 5 instead, and 3 and 6 are terminated.
3.) [1] <= [2] Repeat.
[4] <= [5]
@ambroff
ambroff / patch-keep-slave-data.diff
Created December 21, 2011 23:25
Allow setting up replication without purging data in the slave first.
diff --git a/redis.conf b/redis.conf
index 44fb536..505cb6e 100644
--- a/redis.conf
+++ b/redis.conf
@@ -150,6 +150,13 @@ slave-serve-stale-data yes
#
# repl-timeout 60
+# When setting up replication, the slave will purge the current data set before
+# loading the data sync from the master. Setting this will prevent that from
@ambroff
ambroff / configure.py
Created October 30, 2011 04:01
Configure script for CMake projects. ./configure.py; make; make install; make distclean.
#!/usr/bin/env python
# Copyright (C) 2011 by Kyle Ambroff <kyle@ambroff.com>
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@ambroff
ambroff / gist:1072801
Created July 8, 2011 20:56
Yeah, we went there...
class PHPObjectField(models.Field):
"""Serialize the value in the same format as PHP's built in object
serializer. Yeah I know, it's fucked up. Life's a bitch."""
description = _('PHPObject')
default_error_messages = {
'invalid': _(u'This value must be serializable by PHPserialize.'),}
def get_internal_type(self):
return 'TextField'