Skip to content

Instantly share code, notes, and snippets.

Hao Lee hao-lee

Block or report user

Report or block hao-lee

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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 /
Created Apr 3, 2018
Rename variables in Git history
hao-lee /
Created Mar 19, 2018
Dump package depends from executable file
import subprocess
import re
import sys
result =["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 /
Created Feb 28, 2018
Git: Add prefix to a range of commit messages

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 /
Created Nov 29, 2017
Convert Bazaar repository to Git repository
set -e
if [ $# != 1 ]; then
echo "Usage: ./ bzr_repo/"
exit -1
# 切换进 bzr 仓库
cd "$1"
hao-lee /
Created Nov 24, 2017
Replace keyword in specific line of many files
for file in *.po
for nr in $(awk '/msgstr/{print NR}' "$file")
sed -i "${nr}s/MATE/UKUI/" "$file"
hao-lee /
Created Nov 13, 2017
C language logging example

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.