Skip to content

Instantly share code, notes, and snippets.

View tyru's full-sized avatar
🏠
Working from home

Fujiwara Takuya tyru

🏠
Working from home
View GitHub Profile
@tyru
tyru / kurukuru.rb
Created May 13, 2010 12:49 — forked from jugyo/kurukuru.rb
Use "\r" to back to head of line.
t = Thread.start do
l = '/ - \ |'.split
loop do
c = l.shift
print "\r"
print c
STDOUT.flush
sleep 0.1
l.push c
end
@tyru
tyru / toggle.vim
Created May 6, 2010 07:23 — forked from eagletmt/toggle.js
"toggle bang" in vim script.
function! s:toggle_bang(cmdline)
" :substituteみたいに引数とコマンドの間に
" 空白がなくても呼ばれたりするものもあるので完璧ではない。
" そもそも:substituteはbangとらないけど。
let m = matchlist(a:cmdline, '^\(\s*\)\(\S\+\)\(.*\)')
if empty(m) | return a:cmdline | endif
let [ws, cmd, rest] = m[1:3]
return ws . (cmd[strlen(cmd) - 1] == '!' ? cmd[:-2] : cmd . '!') . rest
endfunction
@tyru
tyru / aawave.rb
Created April 16, 2010 11:37 — forked from ohac/aawave.rb
wave
# -*- coding: utf-8 -*-
require 'curses'
def val2aa(wave, val)
wave[(val + 0x8000) * wave.size / 0x10000]
end
def write_wave(counter)
[
# ['˾_˼ߎ˨-˧H˕ߙ˦˥՟T˺˭'.split(//u), 79], # 文字化けする...
@tyru
tyru / ambicmd.vim
Created April 4, 2010 12:40 — forked from Shougo/ambicmd.vim
ambicmd.vim - You can use ambiguous command.
" You can use ambiguous command.
" Version: 0.2.0
" Author : thinca <[email protected]>
" Shougo <Shougo.Matsu (at) gmail.com>
" tyru <[email protected]>
" License: Creative Commons Attribution 2.1 Japan License
" <http://creativecommons.org/licenses/by/2.1/jp/deed.en>
" Install: copy to autoload/ambicmd.vim
let s:save_cpo = &cpo
" <Tab>: completion.
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : <SID>left_is_keyword() ? "\<C-n>" : "\<Tab>"
function! s:left_is_keyword() "{{{
let col = col('.') - 1
return col != 0 && getline('.')[col - 1] =~# '\k'
endfunction "}}}
@tyru
tyru / .vimrc
Created February 25, 2010 15:00 — forked from c9s/.vimrc
function! s:SelectColorScheme()
30vnew
let files = split(globpath(&rtp, 'colors/*.vim'), "\n")
for idx in range(0, len(files) - 1)
let file = files[idx]
let name = matchstr(file , '\w\+\(\.vim\)\@=')
call setline(idx + 1, name)
endfor