Skip to content

Instantly share code, notes, and snippets.

View hanksudo's full-sized avatar
:octocat:
Follow your passion.

Hank Wang hanksudo

:octocat:
Follow your passion.
View GitHub Profile
@hanksudo
hanksudo / repackage_vagrant_box.md
Last active October 13, 2015 12:05
Repackage Vagrant box
# Update Installed Packages
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install tmux htop git vim wget curl -y

# change default editor
sudo update-alternatives --config editor
@hanksudo
hanksudo / cut_range_of_line_from_file.sh
Created September 30, 2015 06:32
Cut range of line from a file.
#/bin/sh
sed -n 224380,224571p filename.log > piece.log
@hanksudo
hanksudo / install_postgres_on_ubuntu.md
Created September 28, 2015 17:34
Install PostgreSQL 9.4 on ubuntu 12.04, 14.04, 14.10
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >>/etc/apt/sources.list.d/pgdg.list'
wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
@hanksudo
hanksudo / PackerNote.md
Last active September 29, 2015 19:18
Packer Note

Turn off firewall

sudo systemctl start firewalld.service

or add http in

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
@hanksudo
hanksudo / source.list-ubuntu-12.04
Created June 16, 2015 10:42
source.list in China mirror
deb http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ precise-backports main restricted universe multiverse
@hanksudo
hanksudo / checksum.sh
Created June 15, 2015 14:45
OSX: Generate md5 sha1 sha256 checksums from command line
md5 ~/Download/file.iso
shasum -a 1 ~/Download/file.iso
shasum -a 256 ~/Download/file.iso
@hanksudo
hanksudo / fabfile.py
Created June 13, 2015 14:29
Use Fabric with Vagrant
from fabric.api import env, local, run
def vagrant():
env.user = 'vagrant'
env.hosts = ['127.0.0.1:2222']
result = local('vagrant ssh-config | grep IdentityFile', capture=True)
env.key_filename = result.split()[1]
@hanksudo
hanksudo / reproduce_psycopg2.py
Last active June 29, 2017 13:51
(Python) reproduce psycopg2 TransactionRollbackError on ISOLATION_LEVEL_SERIALIZABLE mode
# -*- coding: utf-8 -*-
import psycopg2
from datetime import datetime
# ISOLATION_LEVEL_AUTOCOMMIT
# ISOLATION_LEVEL_READ_COMMITTED
# ISOLATION_LEVEL_REPEATABLE_READ
# ISOLATION_LEVEL_SERIALIZABLE
@hanksudo
hanksudo / geoip_test.py
Created May 4, 2015 16:27
(Python ) geoip2 test script
# -*- coding: utf-8 -*-
from os import path
import geoip2.database
ips = """
223.143.56.227
101.8.221.38
1.34.73.244
42.70.123.135
14.0.209.138