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
def children(zookeeper, path): | |
get_child_path = functools.partial(posixpath.join, path) | |
return [ | |
(name, zookeeper.get_async(get_child_path(name))) | |
for name in zookeeper.get_children(path) | |
] |
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
""" | |
Broken example. | |
""" | |
from cassandra.cluster import Cluster | |
from multiprocessing import Pool | |
size = 4 | |
keyspace = 'system' |
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
>>> class Widget(object): | |
... pass | |
... | |
>>> instance = Widget() | |
>>> method = lambda s: s | |
>>> | |
>>> method.__get__(None, Widget)() | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: unbound method <lambda>() must be called with Widget instance as first argument (got nothing instead) |
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
def SafePool(*args, **kwargs): # XXX: Can't subclass directly | |
# XXX: http://bugs.python.org/issue14881 | |
thread = threading.current_thread() | |
if not hasattr(thread, '_children'): | |
thread._children = weakref.WeakKeyDictionary() | |
return Pool(*args, **kwargs) |
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
Help on module _threading_local: | |
NAME | |
_threading_local - Thread-local objects. | |
FILE | |
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_threading_local.py | |
MODULE DOCS | |
http://docs.python.org/library/_threading_local |
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
import logging | |
root = logging.getLogger() | |
root.setLevel(logging.WARNING) | |
stream = logging.StreamHandler() | |
stream.setLevel(logging.INFO) | |
root.addHandler(stream) | |
root.info('info to root') # this will not be handled |
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
Traceback (most recent call last): | |
File "script.py", line 13, in <module> | |
assert int(lazy) == 1 | |
TypeError: int() argument must be a string or a number, not 'SimpleLazyObject' |
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
CASSANDRA_SOURCE_LIST = /etc/apt/sources.list.d/cassandra.sources.list | |
curl: | |
apt-get install -y curl | |
repository-key: curl | |
curl -L http://debian.datastax.com/debian/repo_key | apt-key add - | |
$(CASSANDRA_SOURCE_LIST): repository-key | |
echo "deb http://debian.datastax.com/community stable main" > $(CASSANDRA_SOURCE_LIST) |
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
ted@aventador % python ~ | |
Python 2.7.2 (default, Jun 20 2012, 16:23:33) | |
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> f1 = 'foo' | |
>>> f2 = 'fo' | |
>>> f2 += 'o' | |
>>> id(f1), id(f2) | |
(4524784296, 4524782976) | |
>>> f1 is f2 |
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
""" | |
Requires ``terminal-notifier``: https://github.com/alloy/terminal-notifier | |
""" | |
import subprocess | |
import weechat | |
name = 'notify' | |
author = 'ted kaemming <[email protected]>' | |
version = '0.0.0' | |
license = 'mit' |