Skip to content

Instantly share code, notes, and snippets.

Steven Cheng stevenc81

Block or report user

Report or block stevenc81

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ipfs-node-docker.sh
docker run -d --name ipfs-node -p 8080:8080 -p 8081:8081 -p 4001:4001 -p 127.0.0.1:5001:5001 ipfs/go-ipfs:v0.4.22
View mongo-shell-with-docker.sh
docker run -it -p 28000:27017 --name mongoContainer mongo:3.6.13 mongo "mongodb+srv://<HOST>/<DB>" --username <USERNAME>
@stevenc81
stevenc81 / Ethereum_PrivateKey_PublicKey_Address.py
Created Jan 6, 2020
Ethereum Private Key to Public Key and Address
View Ethereum_PrivateKey_PublicKey_Address.py
from eth_keys import keys
from eth_utils import decode_hex
# Private key here
priv_key_bytes = decode_hex('0xfbef6fd0f61d054be68aa044d033d83b87ed1bbde658dfa0b4bfdb06e39f6af6')
priv_key = keys.PrivateKey(priv_key_bytes)
pub_key = priv_key.public_key
print(pub_key)
print(pub_key.to_address())
View bip39-standalone.html
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8" />
<title>BIP39 - Mnemonic Code</title>
<style>/*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
View blog-defi-alert.py
from web3 import Web3
import requests
CONTRACT_ADDRESS = '0x39aa39c021dfbae8fac545936693ac917d5e7563'
def main():
w3 = Web3(Web3.HTTPProvider('https://mainnet.infura.io/v3/<YOUR PROJECT ID>'))
r = requests.get(f'https://api.etherscan.io/api?module=contract&action=getabi&address={CONTRACT_ADDRESS}')
checksummed_address = w3.toChecksumAddress(CONTRACT_ADDRESS)
View blog-defi-alert.py
if (total_borrow / total_supply) > 0.65 or liquidity < 10000000000000:
r = requests.post(
'https://api.mailgun.net/v3/<YOUR DOMAIN>/messages',
auth=('api', '<YOUR API KEY>'),
data={'from': 'DeFi Alerts <alerts@defi.com>',
'to': ['<YOUR EMAIL ADDRESS>'],
'subject': "High utilization or low liquidity",
'text': f"Current rate {total_borrow / total_supply}\n" +
f"Current liquidity {liquidity / 1000000}"})
View The Minimalist DeFi Liquidity Alert - An effective way to manage DeFi bank run risk.md

The Minimalist DeFi Liquidity Alert - An effective way to manage DeFi bank run risk

What the hell are you babbling about?

For those who have no idea what the title says, I offer my apology here. Finance by itself is a deep topic with many trade-offs, similar to the world of engineering. According to a greate economists Thomas Sowell

There are no solutions, only trade-offs

In the DeFi (Decentralized Finance) sense, as much as we all love the high interest rates, the trade-offs aren't always clear in this nascent industry. The underlying concept is really simple and sound. It goes something like this:

View special-workload.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
namespace: dev
name: steven-cron
labels:
app: steven-cron
spec:
schedule: "* * * * *"
jobTemplate:
View tainted-nodes.yaml
apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
labels:
kops.k8s.io/cluster: steven.k8s.com
name: frequent-cronjob-nodes
spec:
image: kope.io/k8s-1.13-debian-stretch
machineType: m4.xlarge
maxSize: 2
View Tainting and Labeling Kubernetes Nodes to Run Special Workload - A quick guide that is finally NOT confusing.md

Tainting and Labeling Kubernetes Nodes to Run Special Workload - A quick guide that is finally NOT confusing

All right folks, I intend to keep this one short and that's what I will do. I mean, it's supposed to be easy but the official documentations(1, 2) make it unnecessary confusing. So I think maybe I can help filling in the gap.

I will be using one of our business requirements at Buffer in this project, as the example for this blog post.

Quick recap

So, we need a few nodes that are dedicated to running cronjobs, and nothing else. At the same time we want to make sure the cornjobs are scheduled to these nodes, and nowhere else. This means we need 2 things

You can’t perform that action at this time.