Skip to content

Instantly share code, notes, and snippets.

View AlecZadikian9001's full-sized avatar

AlecZ AlecZadikian9001

  • UC Berkeley
  • Berkeley, CA and Santa Monica, CA
View GitHub Profile
@AlecZadikian9001
AlecZadikian9001 / copy.sh
Created April 25, 2018 18:49
File copy shell script that shows progress
# Tested in Ubuntu 14, requires pv
copy ()
{
echo Copying $1 to $2
cat $1 | pv -a -r -b -p -e -s $(stat --printf="%s" $1) > $2
}
@AlecZadikian9001
AlecZadikian9001 / contract_interact.js
Last active May 13, 2021 14:49
Interacting with an Ethereum contract on mainnet with your own wallet but a third-party node
// Finally figured out how to interact with contracts without running a Geth node or any kind of daemon on my machine.
// Running a Geth node was way harder than I thought. It worked sometimes, randomly broke other times... I lost interest.
// Prerequisites:
// - web3-js 1.0.0, NOT the older versions that have different APIs.
// - An Ethereum wallet for which you have the private key.
// - A public web3-rpc-compatible node. Infura is an easy one: https://infura.io/signup
// - You don't trust the node with your wallet private key
// but do trust that it won't lie to you (maybe you shouldn't).
@AlecZadikian9001
AlecZadikian9001 / multiprocess.py
Last active April 9, 2018 20:02
Python objects for easy multiprocessing and batching
# Created by AlecZ
# Tested with Python 3.4
#
# These example classes make it easy to multiprocess* in Python,
# useful if you want to take advantage of multiple cores on a single machine
# or run lots of low-CPU-usage but blocking tasks like web scrapers
# without configuring a more permanent solution like Celery workers.
#
# * Actually runs multiple Python processes to take advantage of more cores,
# unlike Python's `multithreading` module helpers that actually don't run things in parallel.