Skip to content

Instantly share code, notes, and snippets.

View tzhenghao's full-sized avatar
🏎️

Zheng Hao Tan tzhenghao

🏎️
View GitHub Profile
@tzhenghao
tzhenghao / .gitconfig
Created February 23, 2018 01:09
My Git configs
# This is Git's per-user configuration file.
[user]
name = tzhenghao
email = tanzhao@umich.edu
[alias]
all = add .
cl = clone
@tzhenghao
tzhenghao / aliases.sh
Created February 23, 2018 01:08
A bunch of custom bash/zsh aliases I've used over the past few years
# My own aliases.
alias q='exit'
alias c='clear'
alias h='history'
alias cs='clear;ls'
alias p='cat'
alias pd='pwd'
alias lsa='ls -a'
alias lsl='ls -l'
alias pd='pwd'
@tzhenghao
tzhenghao / extract-stuff.sh
Created February 22, 2018 05:08
Extract tarballs etc.
# Help with extractions
extract () {
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xvjf "$1" ;;
*.tar.gz) tar xvzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xvf "$1" ;;
@tzhenghao
tzhenghao / get_ip_address_v2_simplified.py
Created February 7, 2018 19:25
A simplified version of getting an IP address of a machine
import socket
def get_ip_addresses_v2():
return socket.gethostbyname(socket.gethostname())
@tzhenghao
tzhenghao / get_ip_address_v1.py
Created February 7, 2018 19:23
A naive implementation to query an IP address of a machine
from subprocess import Popen,PIPE
def get_ip_addresses():
c1 = Popen(["ip","addr"], stdout=PIPE)
addr_table = c1.communicate()[0]
addr_table = addr_table.split("\n")
index = 0
while index < len(addr_table):
if "eth0" in addr_table[index]:
break
@tzhenghao
tzhenghao / update-accounts-geth.sh
Last active January 21, 2018 20:00
How to update accounts on Geth
geth account update <ACCOUNT_NUMBER>
#Example:
# geth account update 0
@tzhenghao
tzhenghao / list-accounts-geth.sh
Last active January 21, 2018 19:43
How to list all account(s) via Geth
# List all account(s)
geth account list
# List all account(s) that are under the Ropsten test network
geth --testnet account list
# List all account(s) that are under the Rinkeby test network
geth --rinkeby account list
# sample output 1:
@tzhenghao
tzhenghao / create-account-geth.sh
Last active January 20, 2018 04:29
Create an account via Geth
# Create a new account on main Ethereum network.
geth account new
# Create a new account on the Ropsten network: pre-configured proof-of-work test network
geth --testnet account new
@tzhenghao
tzhenghao / example-server.py
Created January 17, 2018 05:55
Simple Python server script
import socket
import sys
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print 'Socket created'
# Bind socket to local host and port
try:
s.bind(('0.0.0.0', 4010))
except socket.error as msg:
@tzhenghao
tzhenghao / torrc
Created July 9, 2017 10:05
Torrc - ServerAuth demo
HidServAuth abcdefghijklmnop.onion abcdefghijklmnopabcdef