Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Mai-Husan Chia mhchia

View GitHub Profile
@mhchia
mhchia / crawl_ranked_erc20_tokens.py
Last active Jun 24, 2020
This script crawls the top-ranked ERC20 tokens' name and abbreviation from etherscan.io
View crawl_ranked_erc20_tokens.py
"""
This script crawls the top-ranked ERC20 tokens' name and abbreviation from etherscan.io .
"""
from typing import Tuple, Union
import re
from bs4 import BeautifulSoup
import requests
@mhchia
mhchia / asyncctxmgr_fails_when_exiting.py
Created Feb 3, 2020
`async_generator.asynccontextmanager` fails in Python 3.7-dev
View asyncctxmgr_fails_when_exiting.py
import asyncio
from async_generator import asynccontextmanager
@asynccontextmanager
async def async_iterator():
yield 1
View timeit_proto_compare_with_is.py
import random
from multiaddr.protocols import (
Protocol,
PROTOCOLS,
P_IP6ZONE,
)
protocols = tuple(filter(lambda x: x.code != P_IP6ZONE, PROTOCOLS))
@mhchia
mhchia / test_stream_reader_writer.py
Created Mar 8, 2019
timeit benchmark for different implementation of the pipe-like stream reader writer
View test_stream_reader_writer.py
from io import BytesIO
class BytesIOReaderWriter:
_buf: BytesIO
def __init__(self):
self._buf = BytesIO()
def write(self, data):
@mhchia
mhchia / update_libp2p.sh
Created Feb 24, 2019
Copy bindings code from py-libp2p-daemon-bindings to trinity, and modify import paths
View update_libp2p.sh
#!/bin/bash
# TODO: currently only support "bindings to trinity", probably need the reverse direction as well.
echo "Run this script with a new process spun up because of the usage of \`exit\`"
PATH_BINDINGS="$HOME/projects/ethereum/pyeth/py-libp2p-daemon-bindings"
PATH_TRINITY="$HOME/projects/ethereum/pyeth/trinity"
LIBP2P_BINDINGS_PACKAGE="p2pclient"
@mhchia
mhchia / test-proto-tracerstate.go
Last active Aug 10, 2018
To reproduce `proto: duplicate proto type registered: basictracer_go.wire.TracerState`
View test-proto-tracerstate.go
package main
import (
logging "github.com/ipfs/go-log"
appdash "sourcegraph.com/sourcegraph/appdash"
appdashtracer "sourcegraph.com/sourcegraph/appdash/opentracing"
)
func main() {
remoteCollector := appdash.NewRemoteCollector("localhost:8701")
@mhchia
mhchia / test.py
Last active Aug 4, 2017
I fail to use `RLPList` in viper in this case
View test.py
from ethereum.tools import tester as t
from ethereum import utils
import rlp
code = """
def test(a1: bytes <= 1000) -> num:
tempa = RLPList(a1, [num])
return tempa[0]
"""
You can’t perform that action at this time.