Git GC and reflog expire

git reflog expire –expire=now –all # Expire reflog immediately
git gc –prune=now # Remove dangling loose objects
git repack -ad # Remove dangling objects from packfiles (optional)
git fsck –unreachable # Check loose objects connectivity and validity

Python magic methods & mixin

Magic methods:


Docker image size optimization



[Python] Get socket name

import socket

def get_addr4():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((“″, 80))
ip = s.getsockname()[0]
return ip

print get_addr4()

Docker 從入門到實踐

# 匯入image
cat centos7.tar | sudo docker import – test/centos:7
# 進入centos
sudo docker run –name centos -it test/centos:7 bash
# 啟動已休眠的container
sudo docker start centos
# 執行已啟動的container
sudo docker exec -it centos bash
# 匯出container
sudo docker export centos > centos.tar
sudo docker commit -m “Added nodejs" -a “John" debian test/centos:v2