Skip to content

Instantly share code, notes, and snippets.

View violetyk's full-sized avatar

kagaya violetyk

View GitHub Profile
@violetyk
violetyk / gist:97eed8a62e7aa9a133db
Created December 2, 2014 07:02
file_get_contents()エラー判定
<?php
$context = stream_context_create(array(
'http' => array(
'ignore_errors' => true,
'header' => 'User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
)
));
$response = file_get_contents($url, false, $context);
@violetyk
violetyk / .vimrc
Last active August 29, 2015 14:14
vim-sessionの設定
" session {{{
NeoBundle 'xolox/vim-session', {
\ 'depends' : 'xolox/vim-misc',
\ }
" }}}
if neobundle#is_sourced('vim-session') " {{{
let g:session_directory = $HOME . '/.vimsessions/'
let g:session_autoload = 'no'
@violetyk
violetyk / .vimrc
Created January 31, 2015 07:45
yanktmpの設定
NeoBundle 'vim-scripts/yanktmp.vim'
if neobundle#is_sourced('vimyanktmp.vim') " {{{
map <silent> ty :call YanktmpYank()<CR>
map <silent> tp :call YanktmpPaste_p()<CR>
map <silent> tP :call YanktmpPaste_P()<CR>
let g:yanktmp_file = '/tmp/vimyanktmp'
endif " }}}
@violetyk
violetyk / .vimrc
Created January 31, 2015 07:46
easymotionの設定
NeoBundleLazy 'Lokaltog/vim-easymotion'
if neobundle#is_sourced('vim-easymotion') " {{{
" ホームポジションに近いキーを使う
let g:EasyMotion_keys = 'hjklasdfgyuiopqwertnmzxcvbHJKLASDFGYUIOPQWERTNMZXCVB'
let g:EasyMotion_leader_key = "<Space>"
" 1 ストローク選択を優先する
let g:EasyMotion_grouping = 1
" カラー設定変更
hi EasyMotionTarget ctermbg=none ctermfg=red
@violetyk
violetyk / .vimrc
Created January 31, 2015 08:03
breeze.vimの設定
" NeoBundle 'gcmt/breeze.vim'
if neobundle#is_sourced('breeze.vim') " {{{
let g:breeze_highlight_filename_patterns = '*.ctp,*.html,*.htm,*.xhtml,*.xml'
let g:breeze_highlight_tag = 1
let g:breeze_hl_color = 'ctermbg=LightGrey ctermfg=Black guibg=LightGrey guifg=Black '
" nnoremap th :<C-u>BreezeHlElementBlock<CR>
endif " }}}
@violetyk
violetyk / .vimrc
Created January 31, 2015 08:04
PDV--phpDocumentor-for-Vimの設定
NeoBundle 'vim-scripts/PDV--phpDocumentor-for-Vim'
if neobundle#is_sourced('PDV--phpDocumentor-for-Vim') " {{{
inoremap <Leader>d <ESC>:call PhpDocSingle()<CR>i
nnoremap <Leader>d :call PhpDocSingle()<CR>
vnoremap <Leader>d :call PhpDocRange()<CR>
endif " }}}
@violetyk
violetyk / gist:429b885d467d7a5b40d2
Last active August 29, 2015 14:15
md5とsha1とmapのソート
h := md5.New()
io.WriteString(h, "The fog is getting thicker!")
pp.Println(hex.EncodeToString((h.Sum(nil))))
h2 := sha1.New()
io.WriteString(h2, "The fog is getting thicker!")
pp.Println(hex.EncodeToString((h2.Sum(nil))))
s := "http://localhost:8080/xx/yy/zz/hogehoge.png:e?hoge=fuga&k=v#f"
pp.Println(url.QueryEscape(s))
@violetyk
violetyk / gist-file0.md
Last active August 29, 2015 14:20
cakephp3 tutorial

php, composer, mysqlのインストール

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php56 composer mysql

composerの補完

setlocal autoindent
setlocal formatoptions=tcroqln
setlocal nofoldenable
setlocal comments=s1:/*,mb:*,ex:*/,://,b:#,:%,:XCOMM,n:>,b:-,b:+,b:*
abbreviate td [ ]
abbreviate tl - [ ]
nnoremap <silent><buffer> <Leader><Leader> :call ToggleCheckbox()<CR>
vnoremap <silent><buffer> <Leader><Leader> :call ToggleCheckbox()<CR>
@violetyk
violetyk / test.sh
Created August 14, 2015 10:21
docker run をコンテナの並列実行
#!/bin/bash
DIRS=("/bin" "/etc" "/usr") # SUCCESS
# DIRS=("/bin" "/etc" "/usr" "/hogehoge") # FAILURE
IDS=""
for D in ${DIRS[*]}; do
IDS=$IDS" `docker run -d ubuntu du -sh $D`"
done