Skip to content

Instantly share code, notes, and snippets.

View prafulliu's full-sized avatar

Pengfei Liu prafulliu

  • teambition
  • shanghai
View GitHub Profile
@prafulliu
prafulliu / linux 批量替换查找
Created January 3, 2012 07:55
批量替换查找
sed -i "s/floating-point/fixed-point/g" `find . -name "*.xml"|xargs grep floating-point -rl`
http://www.blogjava.net/hispark/archive/2010/08/14/328851.html
@prafulliu
prafulliu / ubuntu添加证书
Created January 3, 2012 07:56
ubuntu添加证书
http://linux.itwaka.com/administer/69448.html
sudo apt-get install libnss3-tools
最终执行如下命令导入根证书:
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n <证书别名> -i <证书文件>
@prafulliu
prafulliu / shuffle lua
Created January 4, 2012 09:58
shuffle
http://www.gammon.com.au/forum/?id=9908
http://blog.fuqcool.com/2011/04/17/algorithm-shuffle.html
http://en.wikipedia.org/wiki/Fisher-Yates_shuffle
@prafulliu
prafulliu / vim批量替换
Created January 4, 2012 09:59
vim批量替换
http://hi.baidu.com/zhmsong/blog/item/7cb17eeaddca8adad539c977.html
:s/XXX/YYY/g
其中XXX是需要替换的字符串,YYY是替换后的字符串
以上这句只对当前行进行替换,如果需要进行全局替换,则要:
%s/XXX/YYY/g
如果需要对指定部分进行替换,可以用V进入visual模式,再进行
:s/XXX/YYY/g
或者可以指定行数对指定范围进行替换:
@prafulliu
prafulliu / vim config
Created January 6, 2012 09:57
vim config
http://spf13.com/post/ultimate-vim-config
@prafulliu
prafulliu / metatable
Created January 8, 2012 09:46
lua metatable
http://www.cnblogs.com/simonw/archive/2007/01/17/622032.html
http://blog.csdn.net/hong201/article/details/4153182
http://www.cnblogs.com/simonw/archive/2006/12/20/597986.html
@prafulliu
prafulliu / fatal: remote origin already exists
Created January 8, 2012 09:57
fatal: remote origin already exists
出现fatal: remote origin already exists. git,可是我就是没有弄过,不知道怎么解决耗了挺久,在网页上看就是没看出来,把网页上的仓库删了还出这个错误,终于找到方法git remote rm origin
重新git remote add origin git@github.com:young001/personal_config.git
最后git push origin master
@prafulliu
prafulliu / tree.md
Created July 23, 2012 14:09 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@prafulliu
prafulliu / set.lua
Created December 18, 2012 03:31
A lua metatable demo.
Set = {}
-- create a new set with the values of the
-- given list
local mt = {}
function Set.new(l)
local set = {}
@prafulliu
prafulliu / readOnlyTables.lua
Created December 18, 2012 07:16
read-only tables in lua.
function readOnly( t )
local proxy = {}
local mt = {
__index = t,
__newindex = function ( t, k, v )
error("attempt to update a read-only table", 2)
end
}
setmetatable(proxy, mt)
return proxy