Skip to content

Instantly share code, notes, and snippets.

@konradkonrad
konradkonrad / message_federation_penetrator.py
Last active November 18, 2020 15:40 — forked from fredo/gist:c8c242c2ca5ba3bba57dcd11d4e42f63
message_federation_penetrator.py
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
"""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.
"""
@konradkonrad
konradkonrad / find_ghost_locksroots.py
Created May 15, 2019 10:51
a script for detecting unrecoverable unlock locksroots
#!/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:
@konradkonrad
konradkonrad / test_and_report.sh
Last active May 8, 2019 10:42
run tests and show coverage report html for raiden
#!/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:-*}
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')
@konradkonrad
konradkonrad / .sh
Created January 31, 2019 11:30 — forked from schmir/.sh
show git status on tab key
# 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
@konradkonrad
konradkonrad / py_watch.py
Last active April 9, 2018 15:53
minimal statusbar watcher
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):
@konradkonrad
konradkonrad / eth_events_grafana.json
Last active January 29, 2018 16:49
Get you started dashboard for grafana & eth.events
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@konradkonrad
konradkonrad / README.md
Last active December 30, 2017 13:18
ethereum blockies-py for terminal
@konradkonrad
konradkonrad / docker-compose.yml
Last active October 27, 2017 09:18 — forked from ulope/docker-compose.yml
prometheus backfill test
version: "2.1"
services:
prom:
image: prom/prometheus
environment:
- TZ=$TZ
volumes:
- ./prom.yml:/etc/prometheus/prometheus.yml
ports: