Skip to content

Instantly share code, notes, and snippets.

danny0838 / .gitconfig
Last active June 23, 2020 22:57
實用的 Git 配置值
quotepath = false # 中文檔名如實顯示而不轉碼
autocrlf = false # commit 及 checkout 時不根據作業系統轉換檔案的換行字元 (避免不小心改動原 repo 的換行字元)
safecrlf = false # 檢查文字類檔案是否混合了 CRLF 及 LF 換行字元 (搭配 autocrlf,這裡一起關閉)
ignorecase = false # 檔名大小寫不同時視為相異 (更動大小寫才能 commit)
whitespace = cr-at-eol # diff 時行尾 CRLF 不顯示 ^M
fileMode = false # 忽略檔案的 x 屬性 (for Windows)
symlinks = false # 忽略符號連結 (for Windows)
editor = /usr/bin/vim # 預設的文字編輯器 (for Linux)
danny0838 /
Last active December 18, 2017 08:15
Prevent codec error when printing to stdout in Python3
#!/usr/bin/env python3
import sys
def safeprint(*args, errors='backslashreplace', **kargs):
Print safely and skips error decode.
Acts like print() with an additional "errors" argument to determine the
error handler for codec errors and accepts non-str-or-None types for the
"sep" and "end" arguments.
danny0838 /
Last active April 18, 2020 11:44 — forked from andris9/
git-cache-meta -- simple file meta data caching and applying.
#!/bin/sh -e
#git-cache-meta -- simple file meta data caching and applying.
#Simpler than etckeeper, metastore, setgitperms, etc.
#modified by n1k
#modified by the-mars
# - save all files metadata not only from other users
# - save numeric uid and gid
# 2012-03-05 - added filetime, andris9