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

http://stevelorek.com/how-to-shrink-a-git-repository.html

https://gitbook.tw/chapters/faq/remove-files-from-git.html

https://stackoverflow.com/questions/5277467/how-can-i-clean-my-git-folder-cleaned-up-my-project-directory-but-git-is-sti

https://ithelp.ithome.com.tw/articles/10138150

廣告

Python magic methods & mixin

Magic methods: http://pycoders-weekly-chinese.readthedocs.io/en/latest/issue6/a-guide-to-pythons-magic-methods.html

Mixin: https://news.ycombinator.com/item?id=7994505

Docker image size optimization

Basic:
https://philipzheng.gitbooks.io/docker_practice/content/image/create.html

Advanced:

https://ypereirareis.github.io/blog/2016/02/15/docker-image-size-optimization/

[Python] Get socket name

import socket

def get_addr4():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect((“8.8.8.8″, 80))
ip = s.getsockname()[0]
s.close()
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
#存入image
sudo docker commit -m “Added nodejs" -a “John" debian test/centos:v2

https://philipzheng.gitbooks.io/docker_practice/content/image/create.html