Skip to content

Instantly share code, notes, and snippets.

View lirenlin's full-sized avatar

Renlin Li lirenlin

View GitHub Profile
@lirenlin
lirenlin / findExec
Created March 8, 2013 09:40
find Makefile recursively and print the path
find . -type f -iname "makefile" -exec basename '{}' \;
@lirenlin
lirenlin / Recursive Makefile
Created March 8, 2013 16:21
Recursive Makefile Example
SUBDIRS = foo bar baz
subdirs:
for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir; \
done
SUBDIRS = foo bar baz
.PHONY: subdirs $(SUBDIRS)
subdirs: $(SUBDIRS)
$(SUBDIRS):
@lirenlin
lirenlin / vim read range
Created March 9, 2013 13:24
read specific range from file into current vim buffer
:r! sed -n 147,227p /path/to/foo/foo.c
@lirenlin
lirenlin / vim command mode completion
Created March 10, 2013 21:23
vim command tab completion
# new option only supported in version >=7.3
set wildignorecase
set wildmenu
set wildmode=list:longest,full
@lirenlin
lirenlin / vim split to open buffer
Last active December 15, 2015 06:59
vertically split window to open buffer, N is the buffer number
vert sbN
# sbN, split window horizontally by default
vsp | bN
@lirenlin
lirenlin / git checkout old commit file
Last active December 15, 2015 06:59
git checkout the file from last commit into new file
git show branch:path_to_file > newFile
git show HEAD:path_to_file > newFile
@lirenlin
lirenlin / vim
Created March 22, 2013 14:18
vim scrolling relative to the cursor
H: put cursor in the top of window
M: put cursor in the middle of window
L: put cursor in the bottom of window
zz:
z.
zt:
z<CR>
@lirenlin
lirenlin / git new ignore
Created July 1, 2013 20:57
remove everything in the index and add new files
git rm -r --cached .
# change the .gitignore file
git add .
git commit -am ""
@lirenlin
lirenlin / get_gist
Created July 5, 2013 18:56
simple script to get the gist of somebody
#!/usr/bin/python
import urllib2
import json
user = "lirenlin"
url = "https://api.github.com/users/%s/gists"
HTML_header = ''' <!DOCTYPE html>
<html>
<head>
<title>Gist from Li Renlin</title>
import QtQuick 1.1
import com.nokia.meego 1.1
Page {
TabGroup {
id: tabGroup
currentTab: tab1
Page {
id: tab1