Skip to content

Instantly share code, notes, and snippets.

Avatar
🏎️

Zheng Hao Tan tzhenghao

🏎️
View GitHub Profile
View .gitconfig
# 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 Feb 23, 2018
A bunch of custom bash/zsh aliases I've used over the past few years
View aliases.sh
# 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 Feb 22, 2018
Extract tarballs etc.
View extract-stuff.sh
# 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 Feb 7, 2018
A simplified version of getting an IP address of a machine
View get_ip_address_v2_simplified.py
import socket
def get_ip_addresses_v2():
return socket.gethostbyname(socket.gethostname())
@tzhenghao
tzhenghao / get_ip_address_v1.py
Created Feb 7, 2018
A naive implementation to query an IP address of a machine
View get_ip_address_v1.py
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 Jan 21, 2018
How to update accounts on Geth
View update-accounts-geth.sh
geth account update <ACCOUNT_NUMBER>
#Example:
# geth account update 0
@tzhenghao
tzhenghao / list-accounts-geth.sh
Last active Jan 21, 2018
How to list all account(s) via Geth
View list-accounts-geth.sh
# 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 Jan 20, 2018
Create an account via Geth
View create-account-geth.sh
# 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 Jan 17, 2018
Simple Python server script
View example-server.py
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 Jul 9, 2017
Torrc - ServerAuth demo
View torrc
HidServAuth abcdefghijklmnop.onion abcdefghijklmnopabcdef