Skip to content

Instantly share code, notes, and snippets.

@xhlwill
xhlwill / count-git-commits.sh
Last active April 28, 2017 07:52
count total commits on current branch - 统计当前分支的提交数
git log | grep -e 'commit [a-zA-Z0-9]*' | wc -l
# 不准确,如果提交信息里有commit ...字样也会计算进去
# UPDATE:
git log --oneline | wc -l
# UPDATE 2:
# get the commit count for a revision (HEAD, master, a commit hash)
git rev-list --count <revision>
# get the commit count across all branches
@xhlwill
xhlwill / .bash_profile
Last active December 27, 2017 18:22
修改 .bash_profile(mac) 或 .bashrc(linux) 让 terminal 能自动补全 git 命令、显示 git 分支等信息 (git-completion.bash 和 git-prompt.sh 放入 ~ 目录)
source ~/git-completion.bash
source ~/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE="true"
export GIT_PS1_SHOWSTASHSTATE="true"
export GIT_PS1_SHOWUNTRACKEDFILES="true"
export GIT_PS1_SHOWUPSTREAM="auto"
export GIT_PS1_SHOWCOLORHINTS="true"
green=$'\e[0;32m'
@xhlwill
xhlwill / ppi.js
Last active April 28, 2017 07:49
calculate the PPI of screen
const ppi = function(height, width, inch) {
return Math.round(Math.sqrt(height*height + width*width) / inch);
}
@xhlwill
xhlwill / react-native-project-error.log
Last active July 3, 2017 13:54
error log of react native project
Found Xcode project AwesomeProject.xcodeproj
Launching iPhone 6 (iOS 9.2)...
Building using "xcodebuild -project AwesomeProject.xcodeproj -scheme AwesomeProject -destination id=076CF12B-FDC4-448D-A592-F9158B9B8C28 -derivedDataPath build"
User defaults from command line:
IDEDerivedDataPathOverride = /Users/lovej/Documents/personal/projects/AwesomeProject/ios/build
=== BUILD TARGET RCTImage OF PROJECT RCTImage WITH CONFIGURATION Debug ===
@xhlwill
xhlwill / Preferences.sublime-settings
Last active May 1, 2017 04:49
sublime text settings
{
"always_show_minimap_viewport": true,
// Goto Anything or Find in Files
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
# pretty git log history
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset %an'
# add it to alias
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset %an'"
# now we can use <git-lg>
git lg
@xhlwill
xhlwill / .vimrc
Created March 26, 2017 08:37
vim configuration
execute pathogen#infect()
syntax enable
set background=dark
colorscheme solarized
filetype plugin on
filetype indent on
set nu
@xhlwill
xhlwill / port.sh
Last active June 6, 2017 04:35
find processes that uses my tcp port
# You can try netstat
netstat -vanp tcp | grep 3000
# For OSX El Capitan and newer (or if your netstat doesn't support -p), use lsof
lsof -i tcp:3000
@xhlwill
xhlwill / show-all-files-in-finder.sh
Last active June 15, 2017 07:16
Display files with names that starts with a dot (.) in Finder
defaults write com.apple.finder AppleShowAllFiles -bool true
killall Finder
# then restart finder
@xhlwill
xhlwill / user-rules.txt
Last active May 12, 2017 05:49
user rules for pac mode
! Put user rules line by line in this file.
! See https://adblockplus.org/en/filter-cheatsheet
||gist.github.com^
||github.io^
||githubusercontent.com^
||s3.amazonaws.com^
||postmates.com^
||imgur.com^
||quora.com^
||quoracdn.net^