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 elasticsearch | |
| from math import log | |
| def tfidf_matrix(es, index, doc_type, fields, size=10, bulk=500, query=dict(match_all=[])): | |
| """Generate tfidf for `size` documents of `index`/`doc_type`. | |
| All `fields` need to have the mapping "term_vector": "yes". | |
| This is the consuming version (i.e. get everything at once). | |
| :param es: elasticsearch client |
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
| from gevent import monkey # isort:skip | |
| monkey.patch_all() # isort:skip | |
| from collections import defaultdict | |
| from typing import List | |
| import gevent | |
| from gevent.event import Event | |
| from matrix_client.errors import MatrixRequestError |
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
| """Types used to represent transaction and its states. | |
| Each state of a transaction is described by a different wrapper dataclass, this | |
| is used to introduce new fields in a type safe manner, and to enforce correct | |
| usage. | |
| Transactions are by design immutable and don't have access in their field to | |
| objects that do IO, that is why the RPC class is given as an argument to each | |
| method, when necessary. | |
| """ |
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
| #!/usr/bin/env bash | |
| # Usage: | |
| # ./solc [options] inputfile > outfile | |
| # Notes: | |
| # - file i/o is limited to the current directory | |
| # - this works with the pyethereum solc_wrapper | |
| docker run -i --rm --user $(id -u):$(id -g) -v $(pwd):/tmp --workdir /tmp ethereum/solc:0.4.18 $@ |
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
| #!/usr/bin/env python | |
| import json | |
| import sys | |
| from collections import defaultdict | |
| from raiden.storage.sqlite import SQLiteStorage | |
| def read_args(): | |
| if len(sys.argv) < 2 or "-h" in sys.argv or "--help" in sys.argv: |
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
| #!/usr/bin/env sh | |
| # pytest executable | |
| PYTEST=${PYTEST:-$(which pytest)} | |
| # specify non temp output directory | |
| OUT_DIR=${OUT_DIR:-$(mktemp -d)} | |
| # which tests to execute | |
| SUITE=${SUITE:-raiden/tests/unit raiden/tests/fuzz} | |
| # report only these files | |
| ONLY=${ONLY:-*} |
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
| from itertools import count | |
| import gevent | |
| from gevent.event import AsyncResult | |
| def wait_twice(async_result): | |
| print('wait_twice enter') | |
| gevent.joinall(set([async_result, async_result]), raise_error=True) | |
| print('wait_twice exit') |
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
| # When Tab is pressed on an empty(!) command line, the contents of the | |
| # directory are printed (`ls`) instead of a menu list of all | |
| # executables: | |
| function my-hg-report() { | |
| tip=$(hg tip 2> /dev/null) || return | |
| echo | |
| hg --config pager.pager= status | |
| echo | |
| hg --config pager.pager= log --limit 5 --style compact |
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 sys | |
| import time | |
| def reprint(msg): | |
| """Print msg from beginning of last line.""" | |
| sys.stdout.write('\r') | |
| sys.stdout.write(str(msg)) | |
| sys.stdout.flush() | |
| def watch(fn, update=0.25): |
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
| #!/usr/bin/env sh | |
| ## Features: | |
| ## - host's working directory is mounted to random location as the container's working directory | |
| ## - uid/gid of the current user are preserved inside the container | |
| ## - a host tmp dir will be mounted as /home/user and published as HOME environment variable inside the container | |
| ## - all EXPOSED ports will be published (check `docker port $(docker ps -q|head -n1)`). | |
| ## - container will be removed on exit | |
| ## | |
| ## Examples: |
NewerOlder