This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Toss me in your /easy-rsa/2.0 path to have a quick and easy way to generat | |
# a key for a new machine, automatically zipped with encryption into /tmp. | |
# Requires that you have the below lines uncommented as part of a pre-configured | |
# client.conf sitting in keys/ . | |
# cert CHANGEME.crt | |
# key CHANGEME.key | |
source ./vars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''async_http_client.py | |
Originally written December 25, 2011 by Josiah Carlson | |
Released into the public domain. | |
This simple asynchat.async_chat subclass offers the ability to connect to http | |
servers to download files. The example download_file() function shows how to | |
use the class to download files from a remote webserver, automatically | |
handling redirects and errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Written January 4, 2012 by Josiah Carlson | |
Released into the public domain. | |
I've only ever needed this once, but I had to learn the descriptor protocol. | |
Works just like a property, except that what you decorate gets the class | |
instead of the instance. | |
class Example(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
This code is derived from: http://code.activestate.com/recipes/576944/ | |
It was released under the MIT license. | |
I (Josiah Carlson) have modified it to be correct in more cases, and to report | |
errors in some error cases. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A proposed method for choosing which slaves to monitor within the | |
# Redis HA sentinel monitors | |
def select_slaves_to_monitor(slave_info, all_sentinels, my_id, my_slaves): | |
''' | |
slave_info = [ | |
('ip_or_host:port', ['sentinel-id, ...]), | |
... | |
] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
chunked_server_test.py | |
Copyright August 3, 2012 | |
Released into the public domain | |
This implements a chunked server using Python threads and the built-in | |
BaseHTTPServer module. Enable gzip compression at your own peril - web | |
browsers seem to have issues, though wget, curl, Python's urllib2, my own | |
async_http library, and other command-line tools have no problems. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''pass_socket.py | |
Written September 14, 2012 | |
Released into the public domain. | |
Works on Python 2.6, 2.7, and may need minor changes for 3+. | |
''' | |
import multiprocessing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''A function to refresh a lock that can timeout, before it times out.''' | |
def refresh_lock(conn, lockname, identifier, lock_timeout=10): | |
pipe = conn.pipeline(True) | |
lockname = 'lock:' + lockname | |
while True: | |
try: | |
pipe.watch(lockname) | |
if pipe.get(lockname) == identifier: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Written December 7, 2012 by Josiah Carlson | |
Released into the public domain. | |
Untested. | |
''' | |
from binascii import crc32 |