This file contains hidden or 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 mitogen | |
import time | |
import traceback | |
import os | |
import mitogen.core | |
@mitogen.core.takes_router |
This file contains hidden or 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 mitogen | |
import requests | |
def get_url(url): | |
return requests.get(url).text | |
@mitogen.main() | |
def main(router): | |
host = router.ssh(hostname='k3') | |
print host.call(get_url, 'https://www.google.com/') |
This file contains hidden or 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
ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/Users/dmw/.ansible/cp/4e8d7ac1b9 u | |
'/bin/sh -c '"'"'echo ~ && sleep 0'"'"'' |
This file contains hidden or 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
ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/Users/dmw/.ansible/cp/4e8d7ac1b9 u '/bin/sh -c '"'"'echo ~ && sleep 0'"'"'' |
This file contains hidden or 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 subprocess | |
import mitogen | |
def main(router): | |
u = router.ssh(hostname='u') | |
root = router.sudo(via=u, password='x') | |
for x in xrange(100): | |
root.call(subprocess.check_call, ['true']) | |
if __name__ == '__main__' and mitogen.is_master: |
This file contains hidden or 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 flags(names): | |
"""Return the result of ORing a set of (space separated) :py:mod:`termios` | |
module constants together.""" | |
return sum(getattr(termios, name) for name in names.split()) | |
def flags(names): | |
"""Return the result of ORing a set of (space separated) :py:mod:`termios` | |
module constants together.""" | |
n = 0 |
This file contains hidden or 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 lmdb | |
def test(): | |
env = lmdb.open("test.lmdb", max_dbs=1, map_size=15*1024*1024) | |
try: | |
value = bytearray(" "*9*1024*1024) | |
with env.begin(write=True, buffers=True) as txn: | |
txn.put("big", value, dupdata=False, overwrite=True) |
This file contains hidden or 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
[23:19:21 k3!2 py-lmdb] ~/pypy-2.4.0/bin/pypy examples/dirtybench.py | |
permutate 1876098 words avglen 13 took 2.74sec | |
DB_PATH: /ram/testdb | |
insert: 3.070s 611142/sec | |
stat: {'branch_pages': 244L, 'entries': 1876098L, 'overflow_pages': 0L, 'psize': 4096, 'depth': 4, 'leaf_pages': 25385L} | |
k+v size 50911.31kb avg 27, on-disk size: 101540.00kb avg 55 | |
enum (key, value) pairs: 0.544s 3447601/sec | |
reverse enum (key, value) pairs: 0.495s 3790924/sec |
This file contains hidden or 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 collections, types | |
class frozendict(collections.UserDict): | |
def __init__(self, d=None, **kw): | |
d = kw if d is None else dict(d, **kw) | |
self.data = types.MappingProxyType(d) | |
self._h = sum(map(hash, self.data.items())) | |
__hash__ = lambda self: self._h | |
__repr__ = lambda self: repr(dict(self)) |
This file contains hidden or 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
/** | |
* Match methods on `obj` of the form "_onCssClassAction", extracting | |
* "CssClass" and "Action", then: | |
* | |
* - Transform "CssClass" to ".cssClass" | |
* - Transform "Action" to "action" | |
* - Find elements matching .cssClass inside `elem` | |
* - Wire up the corresponding jQuery action (e.g. click()) to a bound | |
* copy of the method. | |
* |
NewerOlder