Skip to content

Instantly share code, notes, and snippets.

@caingougou
caingougou / cd 到当前文件目录.vim
Created November 1, 2010 03:04
vim cd 到当前文件目录
:cd %:h
" 或许需要:p参数
@caingougou
caingougou / ubuntu目录或文件打开方式.sh
Created November 1, 2010 03:28
ubuntu目录或文件打开方式
vi .local/share/applications/mimeapps.list
@caingougou
caingougou / 文件中搜索.vim
Created November 1, 2010 07:36
在文件中搜索
:vim[grep][!] /{pattern}/[g][j] {file} ...
"例如
:grep 'test' -r /home/files/*.php
@caingougou
caingougou / vimrc.vim
Created November 2, 2010 08:17
vim配置文件
if v:version < 700
echoerr 'This _vimrc requires Vim 7 or later.'
quit
endif
" 获取当前目录
func! GetPWD()
return substitute(getcwd(), "", "", "g")
endf
@caingougou
caingougou / mb_str_split.php
Created November 5, 2010 05:47
str_split function for multibytes
<?php
function mb_str_split($str, $split_length) {
$chars = array();
$len = mb_strlen($str);
for ($i = 0; $i < $len; $i+=$split_length ) {
$chars[] = mb_substr($str, $i, $split_length); // only one char to go to the array
}
return $chars;
}
@caingougou
caingougou / 强行保存.vim
Created November 9, 2010 01:46
强行保存文档
:w !sudo tee %
@caingougou
caingougou / bootstrap.php
Created November 9, 2010 16:31
Kohanaphp的bootstrap.php中关于404的route的设置
<?php
/**
* 写在所有route后面
*/
Route::set('catch_all', '<path>', array('path' => '.+'))
->defaults(array(
'controller' => 'errors',
'action' => '404',
));
@caingougou
caingougou / hosts.txt
Created November 10, 2010 05:44
hosts文件
174.36.30.71 www.dropbox.com
209.85.225.101 docs.google.com
74.125.127.100 writely.google.com
64.233.183.104 spreadsheets.google.com
64.233.183.104 spreadsheet.google.com
64.233.183.104 spreadsheets2.google.com
209.85.225.101 sites.google.com
209.85.225.101 groups.google.com
#209.85.225.101 code.google.com
@caingougou
caingougou / inline-block.css
Created November 16, 2010 02:29
inline-block for all elements
a {
display: -moz-inline-stack;
display: inline-block;
zoom: 1;
*display: inline;
}
@caingougou
caingougou / remove html tag attributes.vim
Created November 16, 2010 09:27
remove html tag attributes
:%s/<tagname\@=[^/>]*>\@=/<tagname/g