Skip to content

Instantly share code, notes, and snippets.

eli cactus

Block or report user

Report or block cactus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cactus
cactus / alembic.sh
Last active Apr 5, 2017
some examples of helper scripts I use: all files go in an ./env dir inside the project (git ignores them due to gitignore match). then you call them like ./env/run.sh
View alembic.sh
#!/bin/bash
source .tox/py27/bin/activate
source env/env.sh
alembic "$@"
@cactus
cactus / py27.txt
Last active Jun 3, 2019
python-2.7.14 and python-3.7.0 -- for centos7 (rpm fpm recipes)
View py27.txt
##### Configurable options
BUILD_VER=2.7.14
# strip symbols to slightly reduce runtime memory footprint
STRIP="yes"
# use altinstall to NOT symlink python and python2 to the python2.7 executable
ALTINSTALL="yes"
# build as user, requires configured sudo (for yum and fpm gem install).
# if not "yes", then build should be done as root
USE_SUDO="yes"
@cactus
cactus / results.txt
Last active May 20, 2019
python compression comparison
View results.txt
Data Size:
Input: 2074
LZ4: 758 (0.37)
Snappy: 676 (0.33)
LZF: 697 (0.34)
ZLIB: 510 (0.25)
LZ4 / Snappy: 1.121302
LZ4 / LZF: 1.087518
LZ4 / ZLIB: 1.486275
Benchmark: 50000 calls
@cactus
cactus / install-setup.txt
Last active Aug 19, 2019
python serialization speed comparison
View install-setup.txt
virtualenv --no-site-packages hodor
hodor/bin/pip install simplejson ujson cbor tnetstring msgpack-python
curl -s 'http://www.json-generator.com/api/json/get/cvfsLVmKiG?indent=2' > test.json
hodor/bin/python shootout.py
@cactus
cactus / .netrc
Last active Mar 1, 2017
example netrc
View .netrc
# .netrc
## generate token with https://help.github.com/articles/creating-an-oauth-token-for-command-line-use
machine github.com login <token>
View gist:2934592
>>> rows = [(1,2,3), (4,5,6), (7,8,9)]
>>> [','.join(map(str,row[offset:offset+3]))
... for offset in range(0, len(rows) / 3)
... for row in rows]
['1,2,3', '4,5,6', '7,8,9']
@cactus
cactus / gist:2556514
Created Apr 30, 2012
socketpool memcache example
View gist:2556514
# -*- coding: utf-8 -
#
import logging
import random
import memcache
import gevent.socket
# monkey patch to patch sockets
memcache.socket = gevent.socket
from socketpool.pool import ConnectionPool, MaxTriesError
View gist:1234373
import functools
def _decorate_method(f, name):
@functools.wraps(f)
def __wrapper(self, *args, **kwds):
print 'wrapped a method', f, name
return f(self, *args, **kwds)
return __wrapper
View gist:1141631

A poem about laundry.

I just did laundry.
I shrank a hooded sweatshirt.
I suck at laundry.

Originally posted on: 2005-11-28 (old blog post)

@cactus
cactus / rack_date.rb
Created Dec 22, 2010
Rack::Date middleware
View rack_date.rb
## Rack middleware for adding a Date http header
## Some http servers do not set this, so use only if necessary
require 'time'
module Rack
class Date
def initialize(app)
@app = app
end
def call(env)
You can’t perform that action at this time.