Skip to content

Instantly share code, notes, and snippets.

View dmuhs's full-sized avatar
:octocat:
Gitting all the Hubs

Dominik Muhs dmuhs

:octocat:
Gitting all the Hubs
View GitHub Profile
@dmuhs
dmuhs / infura-finder.py
Created February 7, 2022 11:20
A helper script to identify Infura project URLs in link lists. Works with stdin and explicit arguments. Toggle `INCLUDE_TESTNETS` to limit results to mainnets only.
import re
import sys
import requests
from requests import Response
INCLUDE_TESTNETS = True
if INCLUDE_TESTNETS:
NETWORK_FRAGMENT = "(mainnet|ropsten|rinkeby|kovan|goerli|polygon-mainnet|polygon-mumbai|optimism-mainnet|optimism-kovan|arbitrum-mainnet|arbitrum-rinkeby)"
else:
import requests
import json
from eth_account import Account
from eth_account.account import SignedMessage
from eth_account.messages import encode_defunct
acct = Account.from_key("0x95991b18f2789c5d9a0b3bfe08f635bfe40080b2c6b3bdd9dac338e4023eec42")
annotation = {
"@context": ["https://pan.network/annotation/v1"],
ciphertext = """tlChuoeln lgbarlbauyte ubslitaratdris o lnaesrm,eo nya o dugr'rovopeus p p crohofiv memnnee dyyi outumor-psssei lzbfel dua,e wmbooirsrttdhlsyy lciuhnlasllealcbetyni gvseotrra orau nsld e omsroo nlo vmdenrdio vptoshr eoc uhfsii mfbntiehry d rsto ouipnnsd !tb
hlYeuo euo rrb diferirdn sao lfl ucPllalusaesb eyir sis:nt ea"srb lilunee m tobhnie r ddgrseo"np
usNs o cwSh iigamoln ietayo ottfoh pets h Weba lltukhetr hubrsiohru dgfsha mlWiuollrylk as(bhTyou prssdt iasdrta aelf)ef.m otBnal budlerebo ipirsnd sct hhaierm enp eaoycn kete otop fsh atbchlkeui enf geb wiv ritdlhslr aulgsuehl l(gaiebfny e yrsoatu a'irrn e l tenhmoeot n A tmdhereroripecs a ascl.hr ieTmahndeeyyy) htaaonvpdes nbballmuueee , t bhoiarrt d bssl oulneug l!"""
i = 0
res = ""
while True:
res += ciphertext[i % len(ciphertext)]
if len(res) == len(ciphertext):
def is_valid_log_entry(entry):
level_valid = entry.get("level") in ("info", "warning", "error")
message_valid = type(entry.get("message")) == str
return all((level_valid, message_valid))
def is_valid_log_entry(log_entry):
if log_entry.get("level") not in ("info", "warning", "error"):
return False
if "message" not in log_entry.keys():
return False
return True
def remove_duplicate_logs(log_list: List[Dict[Any, Any]]):
# taken from https://stackoverflow.com/questions/9427163/remove-duplicate-dict-in-list-in-python
class MyLogHandler:
...
@staticmethod
def groom_logs(my_artifact):
log_list = my_artifact.get("logs")
if log_list is None:
return
def is_valid(log_entry):
if log_entry.get("level") not in ("info", "warning", "error"):

Keybase proof

I hereby claim:

  • I am dmuhs on github.
  • I am dmuhs (https://keybase.io/dmuhs) on keybase.
  • I have a public key ASBT-A9wrOfLXRD0ZO5CWsIQOfui-AbRSaBZCyfOBrQdOwo

To claim this, I am signing this object:

@dmuhs
dmuhs / validator-bench.py
Created December 17, 2018 17:59
Comparing the speed of a string-based and a regex-based Solidity function signature validator
from timeit import timeit
import re
def string_based_validator(t):
if not t.endswith(')'):
return False
lp = t.index('(')
name = t[:lp]
In [1]: hash("foo")
Out[1]: -6427459509433145349
In [2]: hash("foo")
Out[2]: -6427459509433145349
<restart Python process...>
In [1]: hash("foo")
Out[1]: -7165618396328893146
In [2]: hash("foo")
def search_children(statespace, node, start_index=0, depth=0, results=None):
if results is None:
results = []
if depth < MAX_SEARCH_DEPTH:
n_states = len(node.states)
if n_states > start_index:
for j in range(start_index, n_states):
if node.states[j].get_current_instruction()['opcode'] == 'SSTORE':
results.append(node.states[j].get_current_instruction()['address'])
...