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
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.