Skip to content

Instantly share code, notes, and snippets.

View saihoooooooo's full-sized avatar
♨️
noop

shinya.saiho saihoooooooo

♨️
noop
View GitHub Profile
@saihoooooooo
saihoooooooo / gist:1850693
Created February 17, 2012 04:32
Diff update with check value of 'diff'
nnoremap <silent>du :<C-u>call DiffUpdate()<CR>
function! DiffUpdate()
if &diff
diffupdate
else
" dummy E99
echohl ErrorMsg | echo 'E99: Current buffer is not in diff mode' | echohl None
endif
endfunction
@saihoooooooo
saihoooooooo / gist:1880918
Created February 22, 2012 02:51
open tab for diff
nnoremap <C-d> :<C-u>silent call OpenDiffWindow()<CR>
function! OpenDiffWindow()
execute "normal \<C-t>"
setlocal bufhidden=unload nobuflisted buftype=nofile noswapfile
file [Diff Right]
vnew
setlocal bufhidden=unload nobuflisted buftype=nofile noswapfile
file [Diff Left]
windo diffthis
endfunction
@saihoooooooo
saihoooooooo / gist:2048199
Created March 16, 2012 02:44
file encode check
find -name "*.tpl" | xargs nkf -g | grep -v "UTF-8" | grep -v "ASCII"
@saihoooooooo
saihoooooooo / gist:2259435
Created March 31, 2012 04:52
indent html for smarty template
" HTMLインデント
command! HtmlIndent call <SID>HtmlIndent()
function! s:HtmlIndent()
%s/>\zs\ze</\r/g
let old = &filetype
set filetype=html
normal! ggVG=
let &filetype = old
endfunction
@saihoooooooo
saihoooooooo / gist:2366780
Created April 12, 2012 11:49
change colorscheme when open buffer of network file
let g:switch_colorscheme_config = {
\ '172.28.20.7' : 'murphy',
\ }
let g:switch_colorscheme_default = 'nevfn'
autocmd MyAutoCmd BufEnter * call <SID>switchColorscheme()
function! s:switchColorscheme()
let color = ''
for [key, value] in items(g:switch_colorscheme_config)
if @% =~ key
let color = value
@saihoooooooo
saihoooooooo / gist:2375671
Created April 13, 2012 10:34
php measure time
<?php
class Unko
{
public function func()
{
$totalnow = $now = $this->_measureTime();
some();
$now = $this->_measureTime(__LINE__, $now);
some2();
@saihoooooooo
saihoooooooo / gist:2403700
Created April 17, 2012 05:27
my vim statusline
let &statusline = ''
let &statusline .= '%{expand("%:t")}'
let &statusline .= '%h%w%m%r'
let &statusline .= ' (%<%{expand("%:p:~:h")}) '
let &statusline .= '%='
let &statusline .= '[HEX:%B][R:%l][C:%c]'
let &statusline .= '%y'
let &statusline .= '[%{&fileencoding != "" ? &fileencoding : &encoding}]'
let &statusline .= '%{&bomb ? "[BOM]" : ""}'
let &statusline .= '[%{&fileformat}]'
@saihoooooooo
saihoooooooo / gist:2992690
Created June 26, 2012 01:55
make post data from form
$.makePostData = function(formSelector) {
var postData = {};
$(formSelector).find(':input').each(function(){
if (typeof $(this).attr('name') === 'undefined') {
// name属性の無いフォームは無視
} else if ($(this).attr('name').match(/\[\]$/)) {
if (typeof postData[$(this).attr('name')] === 'undefined') {
postData[$(this).attr('name')] = [$(this).val()];
} else {
postData[$(this).attr('name')].push($(this).val());
@saihoooooooo
saihoooooooo / gist:3087151
Created July 11, 2012 00:35
set up zencoding
let g:user_zen_settings = {
\ 'lang' : 'ja',
\ 'indentation' : ' ',
\ 'html' : {
\ 'filters' : 'html',
\ 'snippets' : {
\ 'jq' : "<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js\"></script>\n<script>\n\\$(function() {\n\t|\n})();\n</script>",
\ 'cd' : "<![CDATA[|]]>",
\ },
\ },
@saihoooooooo
saihoooooooo / gist:3430909
Created August 23, 2012 00:47
webdict sample
" wiktionary
let g:ref_source_webdict_sites = {
\ 'wiktionary': {
\ 'url': 'http://ja.wiktionary.org/wiki/%s',
\ 'keyword_encoding': 'utf-8',
\ 'output_encoding': 'euc-jp',
\ 'cache': 1,
\ }
\ }
function! g:ref_source_webdict_sites.wiktionary.filter(output)