Skip to content

Instantly share code, notes, and snippets.

View Nan-Zhang's full-sized avatar

Nan-Zhang

  • San Francisco Bay Area
View GitHub Profile
mv !(fileOne) ~/path/newFolder
@Nan-Zhang
Nan-Zhang / gist:4012a6a3c61ebff69340
Created March 6, 2015 23:41
disable line number when copying using mouse in vim
:se nonu
Shift + V for visual line to select the lines in visual mode
If all that is wanted is to display the name of the current file, type Ctrl-G (or press 1 then Ctrl-G for the full path).
@Nan-Zhang
Nan-Zhang / rmspaces.md
Last active August 29, 2015 14:12
remove unwanted spaces in the beginning of line in vim

To format a line to the left I use :left. Use this format an entire file:

:%le

count the number of phone number

grep -E "[0-9]{3}-[0-9]{7}" ./test/* | wc -l

show the filename which contain the phone number

grep -lE "[0-9]{3}-[0-9]{7}" ./test/*
-E activates regular expressions (you could use egrep instead)

-l filters grep results, only the file name will be printed

export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
The first line changes the bash prompt to be colorized, and rearranges the prompt to be “username@hostname:cwd $”
The next two lines enable command line colors, and define colors for the ‘ls’ command
Finally, we alias ls to include a few flags by default. -G colorizes output, -h makes sizes human readable, and -F throws a / after a directory, * after an executable, and a @ after a symlink, making it easier to quickly identify things in directory listings.
show ith of a: a & 1 << i
reset ith of a: a &= ~(1 << i)
populate the result: result |= 1 << i
(-i) & i; //NOTE from right to left, get first '1' and other bits is '0'
n & (n - 1) == 0 check if n is power of 2
1. git log -1 --stat
1. Type gg to move the cursor to the first line of the file, if it is not already there.
2. Type dG to delete all the lines.
Up Ctrl+P
Down Ctrl+N
Left Ctrl+B
Right Ctrl+F
Home Ctrl+A
End Ctrl+E
Delete Ctrl+D
Search Ctrl+R