Skip to content

Instantly share code, notes, and snippets.

@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'
@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 / 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 / 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]
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 / 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
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 / app.yaml
Created October 21, 2014 03:42
kinesis from appengine
application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.application
@ambroff
ambroff / gist:367159b3931678305eb1
Last active August 29, 2015 14:18
exercism.io stack trace when uploading a big-endian utf-16 file with submit.
22:00:02 web.1 | started with pid 3368
22:00:05 web.1 | Puma 2.11.1 starting...
22:00:05 web.1 | * Min threads: 0, max threads: 16
22:00:05 web.1 | * Environment: development
22:00:05 web.1 | * Listening on tcp://localhost:4567
22:00:09 web.1 | I, [2015-04-03T22:00:09.373125 #3368] INFO -- : get http://x.exercism.io/problems/cpp/anagram
22:00:09 web.1 | D, [2015-04-03T22:00:09.374105 #3368] DEBUG -- request: User-Agent: "github.com/exercism/exercism.io"
22:00:14 web.1 | I, [2015-04-03T22:00:14.611453 #3368] INFO -- Status: 200
22:00:14 web.1 | D, [2015-04-03T22:00:14.613721 #3368] DEBUG -- response: server: "Cowboy"
22:00:14 web.1 | date: "Fri, 03 Apr 2015 22:00:16 GMT"
@ambroff
ambroff / gist:430be29f6acd313dc3e3
Last active August 29, 2015 14:18
Proper decoding
diff --git a/api/iteration.go b/api/iteration.go
index 49b833a..01eea02 100644
--- a/api/iteration.go
+++ b/api/iteration.go
@@ -5,6 +5,13 @@ import (
"io/ioutil"
"path/filepath"
"strings"
+
+ "golang.org/x/net/html/charset"