This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " オブジェクト指向風 Vim script で再帰してみる | |
| function! s:factorial() dict | |
| return self.value == 0 ? | |
| \ 1 : self.value * s:Int.new(self.value - 1).factorial() | |
| endfunction | |
| function! s:new(n) dict | |
| let _ = deepcopy(s:Int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " matchparen の対応括弧強調のハイライトを下線だけにしておとなしくする | |
| " GVim では問題ないが端末では対応していない場合があるかも | |
| augroup silent-matchparen | |
| autocmd! | |
| autocmd VimEnter,WinEnter,ColorScheme * | |
| \ highlight MatchParen | |
| \ guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE | |
| \ term=underline cterm=underline gui=underline | |
| augroup END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " BufRead イベントを一時的に無効にして vimgrep の所要時間を通常の約三分の一にする | |
| " 注意: 圧縮されたファイルを読むようなプラグインが動作しなくなるという副作用がある | |
| augroup faster-vimgrep | |
| autocmd! | |
| autocmd QuickFixCmdPre *vimgrep* | |
| \ let s:save_eventignore = &eventignore | |
| \ | set eventignore=BufRead | |
| autocmd QuickFixCmdPost *vimgrep* | |
| \ let &eventignore = s:save_eventignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Vim script で Observer pattern を書いてみた | |
| " 参考URL: http://ja.wikipedia.org/wiki/Observer_%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3 | |
| function! s:listenerNew(name, subject) dict | |
| let this = deepcopy(self) | |
| let this.name = a:name | |
| call a:subject.register(this) | |
| return this | |
| endfunction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;(function() { | |
| var collatz = function(i) { | |
| var list = [i]; | |
| while (list.slice(-1) > 1) { | |
| var n = list.slice(-1); | |
| if (n % 2 === 0) { | |
| n = n / 2; | |
| } else { | |
| n = 3 * n + 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'yaml' | |
| require 'awesome_print' | |
| if ARGV.empty? || ARGV.first == '-h' || ARGV.first == '--help' | |
| puts "Usage: #{File.basename($0)} [yaml file]" | |
| exit | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| call feedkeys("\<Esc>:echo system(\"find ~ -name 'Icon\<C-v>\<C-m>'\")\<CR>", 'n') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # See: https://plus.google.com/103883213408660487064/posts/EmxndYMnSxm | |
| require 'date' | |
| puts (Date.new(1990,1,1)..Date.new(2015,2,11)).count(&:sunday?) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ ruby -e 'ENV["PATH"].split(":").map{|path| Dir["#{path}/*"]}.flatten.map{|path| File.basename(path)}.select{|str| str.include?("-") || str.include?("_")}.sort.each{|it| puts it}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # quicklook wrapper script | |
| if [ "$1" = '-v' ] | |
| then | |
| shift | |
| qlmanage -p -d 4 "$@" | |
| else | |
| qlmanage -p "$@" >/dev/null 2>&1 | |
| fi |