Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am 72squared on github.
  • I am 72squared (https://keybase.io/72squared) on keybase.
  • I have a public key ASCjN-0_CyV0BlLwlQj7pSpi4x5GgmVmw4Izd3e4OL0Wego

To claim this, I am signing this object:

#!/usr/bin/env python
import rediscluster
import uuid
import sys
import time
def create_connection():
startup_nodes = [
{'host': '127.0.0.1', 'port': 7000},
{'host': '127.0.0.1', 'port': 7001},
# install pypy binary
cd /opt && wget "https://s3-us-west-2.amazonaws.com/hb-apt-repo/apt/pypy-5.1.1-linux64.tar.bz2" -O - | tar -xj
# set up virtualenv
virtualenv -p /opt/pypy-5.1.1-linux64/bin/pypy /opt/venv-redisimp
# install redisimp
source /opt/venv-redisimp/bin/activate && pip install -e git://github.com/happybits/[email protected]#egg=redisimp
import gevent
__all__ = ['RedisReplay']
class _RedisReplayPipeline(object):
def __init__(self, primary_pipe, replay_pipe):
self._primary_pipe = primary_pipe
self._replay_pipe = replay_pipe
import aerospike
import unittest
import uuid
import time
from base64 import urlsafe_b64encode
def xid():
return urlsafe_b64encode(uuid.uuid4().bytes).rstrip('=')
class FirstTest(unittest.TestCase):
@72squared
72squared / aerospike_async.py
Created May 25, 2016 12:21
some pseudo-code for what an async api for aerospike in python might look like.
config = {'hosts': [('127.0.0.1', 3000)]}
client = aerospike.client(config).connect()
foo_future = client.put_async(('test', 'demo', 'foo'), {'bin1': 1, 'bin2': 2})
bar_future = client.put_async(('test', 'demo', 'bar'), {'bin1': 1, 'bin2': 2})
bazz_future = client.get_async(('test', 'demo', 'bazz'))
foo_future.result()
bar_future.result()
bazz_future.result()
import threading
import unittest
import sys
from functools import wraps
import time
class Async(threading.Thread):
def __init__(self, target, args=(), kwargs=None):
# download pypy
wget "https://bitbucket.org/pypy/pypy/downloads/pypy-5.1.1-linux64.tar.bz2" -O - | tar -xj
# create virtual env with pypy
virtualenv -p pypy-5.1.1-linux64/bin/pypy .venv
# activate virtual environment
source .venv/bin/activate
# install uwsgi and gevent
import random
import sys
import ws
from connectors import redis_connection_settings
from txredis.client import RedisSubscriber
from autobahn.twisted.websocket import WebSocketServerFactory, listenWS
from twisted.python import log
from twisted.internet import reactor, protocol
from rediscluster import RedisCluster
import time
print "starting"
startup_nodes = [{"host": "127.0.0.1", "port": 7000}]
r = RedisCluster(startup_nodes=startup_nodes, max_connections=32, decode_responses=True)
start = time.time()
for i in xrange(1000):
d = str(i)
pipe = r.pipeline(transaction=False)