Skip to content

Instantly share code, notes, and snippets.

Hao Lee hao-lee

View GitHub Profile
View git-diff-bug.txt
H4sIAAAAAAAAA+3T0W6CMBQGYG7hKc7uIGGxleqNc6/SVC0TbSihJW7Zy68M5oUXYzfMmPwfCW3o
OS1p8ltziObGgrUQ32NwO7KiYBEv1owJwVc8fOdsKYqI2Ox/FnTOq5Yoaq31v9VNrT8oSvonPiun
atnYytlaOqN2aaPedLZZLPpVd+zK0mja0jiTZau1qZxPXU7XyiSuSkqfxpqMPpM4Lm0rtdofpd2d
9N7L6vCeNjmFIafQ21++H7Z4fh1K3NAYO+27Zmz7OSa8s02/2B9kqrM2H2nYil5udsiSe9/ro6j1
ZfYzpvLP+TX/hVgO+V8J5P8/TOT/r+lH3gAAAAAAAAAAAAAAAAAAAADu5Atav98mACgAAA==
@hao-lee
hao-lee / .vimrc
Last active Nov 25, 2018 — forked from rocarvaj/.vimrc
Minimal .vimrc for C/C++ developers
View .vimrc
" VIM Configuration File
" Description: Optimized for C/C++ development, but useful also for other things.
" Author: Gerhard Gappmeier
"
set guifont=hack\ 12
" set UTF-8 encoding
set enc=utf-8
set fenc=utf-8
set termencoding=utf-8
@hao-lee
hao-lee / rename_variables_in_Git_history.md
Created Apr 3, 2018
Rename variables in Git history
View rename_variables_in_Git_history.md
@hao-lee
hao-lee / dump_apt_depends_from_elf.py
Created Mar 19, 2018
Dump package depends from executable file
View dump_apt_depends_from_elf.py
import subprocess
import re
import sys
result = subprocess.run(["ldd", sys.argv[1]], stdout=subprocess.PIPE)
p = re.compile("=>\s([/a-zA-Z0-9\._-]+)")
output = result.stdout.decode("utf-8")
so_list = p.findall(output)
package_list = []
@hao-lee
hao-lee / git-add-commit-msg-prefix.md
Created Feb 28, 2018
Git: Add prefix to a range of commit messages
View git-add-commit-msg-prefix.md

Original Link

Imagine that you cloned an open source project to contribute something. You implemented a bugfix through a series of atomic commits on a private branch. Just when you’re about to create a Pull Request to submit your changes, you discover in the contributor’s guide that you’re supposed to prefix each commit with the bug tracking number.

Rewriting the commit message of the last commit is easy:

git commit --amend
@hao-lee
hao-lee / bzr-to-git.sh
Created Nov 29, 2017
Convert Bazaar repository to Git repository
View bzr-to-git.sh
#!/bin/bash
set -e
if [ $# != 1 ]; then
echo "Usage: ./bzr-to-git.sh bzr_repo/"
exit -1
fi
# 切换进 bzr 仓库
cd "$1"
@hao-lee
hao-lee / sed-keyword-in-specific-line.sh
Created Nov 24, 2017
Replace keyword in specific line of many files
View sed-keyword-in-specific-line.sh
for file in *.po
do
for nr in $(awk '/msgstr/{print NR}' "$file")
do
sed -i "${nr}s/MATE/UKUI/" "$file"
done
done
@hao-lee
hao-lee / logging.md
Created Nov 13, 2017
C language logging example
View logging.md

logger function

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>

char *logfile;
You can’t perform that action at this time.