Skip to content

Instantly share code, notes, and snippets.

import puresnmp
from prometheus_client.core import REGISTRY, GaugeMetricFamily
from prometheus_client import start_http_server
class AirPortExporter:
def collect(self):
in_bytes = puresnmp.get('10.0.1.1', 'public', '1.3.6.1.2.1.2.2.1.10.1')
out_bytes = puresnmp.get('10.0.1.1', 'public', '1.3.6.1.2.1.2.2.1.16.1')
import ujson
import asyncpg
class DB:
def __init__(self):
self.pool = None
async def init(self, *args, **kwds):
@banteg
banteg / buffidai.py
Last active February 21, 2019 06:32
ethdenver vendor statistics
from dataclasses import dataclass
from operator import attrgetter
from web3 import Web3, HTTPProvider
from web3.utils.filters import construct_event_filter_params
from tabulate import tabulate
@dataclass
class Vendor:
address: str
@banteg
banteg / maker_votes.py
Created December 19, 2018 03:38
recover makerdao governance votes
import json
from collections import Counter, defaultdict
from dataclasses import dataclass, field
from decimal import Decimal
from eth_abi import encode_single
from eth_utils import function_signature_to_4byte_selector, decode_hex, encode_hex
from itertools import count
from web3.auto import w3
miner count
e7f7634e925541f368b827ad5c72421905100f6205285a78c19d7b4a38711805 54578
93ac6ca68b2540453261abdb962e3fdb878a5523c08caf9c4079aef92d3177be 37029
0e92c6030a05010c1e7bd40b7d8261fe5e9da2821d1411e3e440cb773463679a 13541
a248289e385c7cbac252eae9b03577c5d3f3a9a7a1f67ed43c65e9318dd65c18 12039
96cfb7db1a5f6989e5624c7dd81b5a2b3ebe1ddfd849ecba7cfdce15d201b0c9 11631
f37d819fc4a6e80286557807e0d39a66ff448daf355363da807902621e374ef0 9083
40c204ee9d55aba202e76c457c7ac0afccf7bce8768d2bb0f4696605eb342123 7722
d30c907adc0000d8a54e8c4f0843d05c500da3c2faa0fe943e085ab278abe751 7496
834ec56e02fbddf69886c3b2801fc39dad301c0d05406843288fb8f79c45b5c6 4644
import json
from collections import Counter, defaultdict
from dataclasses import dataclass, field
from decimal import Decimal
from itertools import chain
import requests
from eth_abi import encode_single
from eth_utils import function_signature_to_4byte_selector, decode_hex, encode_hex
from itertools import count
import requests
import click
LTO_NODE_URL = 'http://127.0.0.1:6869'
LTO_API_KEY = '<your api password>'
s = requests.session()
s.headers['X-API-Key'] = LTO_API_KEY
@banteg
banteg / get_tokens.py
Last active August 13, 2021 04:07
get all tokens a user has interacted with
from web3 import Web3, HTTPProvider
from eth_utils import encode_hex, event_signature_to_log_topic
from eth_abi import encode_single
w3 = Web3(HTTPProvider('http://127.0.0.1:8545', {'timeout': 120}))
transfer_topic = encode_hex(event_signature_to_log_topic('Transfer(address,address,uint256)'))
def get_tokens(address):
from ecdsa import SigningKey, SECP256k1
from sha3 import keccak_256
import click
@click.command()
@click.argument('count', type=click.types.IntRange(1, 1000), default=1)
def main(count):
for i in range(count):
priv, addr = generate_pair()
from ecdsa import SigningKey, SECP256k1
from sha3 import keccak_256
priv = SigningKey.generate(curve=SECP256k1)
pub = priv.get_verifying_key().to_string()
address = keccak_256(pub).hexdigest()[24:]
print(f'private key: 0x{priv.to_string().hex()}')
print(f'public key: 0x{pub.hex()}')
print(f'address: 0x{address}')