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
""" | |
Dynamic pattern matching in except clauses. | |
You can use `ABCMeta` and `__subclasshook__` to implement pattern matching in | |
except clauses. For this demo we're doing two things: first, we're creating | |
exception classes dynamically by overridding `__getattr__` on a metaclass, | |
which itself inherits from `abc.ABCMeta`. This allows us to do this: | |
>>> Errno | |
<class 'dynerror.Errno'> |
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
# TO_FOLDER=/something | |
# FROM=/your-es-installation | |
DATE=`date +%Y-%m-%d_%H-%M` | |
TO=$TO_FOLDER/$DATE/ | |
echo "rsync from $FROM to $TO" | |
# the first times rsync can take a bit long - do not disable flusing | |
rsync -a $FROM $TO | |
# now disable flushing and do one manual flushing |
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
"""The :mod:`zmq` module wraps the :class:`Socket` and :class:`Context` found in :mod:`pyzmq <zmq>` to be non blocking | |
""" | |
__zmq__ = __import__('zmq') | |
from gevent.hub import _threadlocal | |
from gevent.socket import wait_read, wait_write | |
__patched__ = ['Context', 'Socket'] | |
globals().update(dict([(var, getattr(__zmq__, var)) | |
for var in __zmq__.__all__ | |
if not (var.startswith('__') |
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
(defun search-all-buffers (regexp prefix) | |
"Searches file-visiting buffers for occurence of REGEXP. With | |
prefix > 1 (i.e., if you type C-u \\[search-all-buffers]), | |
searches all buffers." | |
(interactive (list (grep-read-regexp) | |
current-prefix-arg)) | |
(message "Regexp is %s; prefix is %s" regexp prefix) | |
(multi-occur | |
(if (member prefix '(4 (4))) | |
(buffer-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
import gevent | |
from gevent import socket, queue | |
from gevent.ssl import wrap_socket | |
import logging | |
logger = logging.getLogger('irc') | |
logger.setLevel(logging.DEBUG) | |
ch = logging.StreamHandler() |
NewerOlder