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 / .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
" <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 / 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 <thinca+vim@gmail.com>
" Shougo <Shougo.Matsu (at) gmail.com>
" tyru <tyru.exe@gmail.com>
" 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
@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 / 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 / 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 / r.scm
Created June 24, 2010 18:48 — forked from mattn/r.go
(R)
(define R
(lambda ()
(print "商標登録です。")
R))
(((((R)))))
(function () {
if (prompt() == 'ujihisa') {
var Ujihisa = new Function();
Ujihisa.prototype.hi = function () { alert("my name is ujihisa"); };
var the_class = Ujihisa;
}
else {
var Ujm = new Function();
Ujm.prototype.hi = function () { alert("this is a pen"); };
var the_class = Ujm;
@tyru
tyru / .vimrc
Created July 14, 2010 14:16 — forked from mmisono/.vimrc
submode: changing window size
call submode#enter_with('winsize', 'n', '', 'mws', ':<C-u>call VimrcSubmodeResizeWindow()<CR>')
call submode#leave_with('winsize', 'n', '', '<Esc>')
function! VimrcSubmodeResizeWindow()
let curwin = winnr()
wincmd j | let target1 = winnr() | exe curwin "wincmd w"
wincmd l | let target2 = winnr() | exe curwin "wincmd w"
execute printf("call submode#map ('winsize', 'n', 'r', 'j', '<C-w>%s')", curwin == target1 ? "-" : "+")
execute printf("call submode#map ('winsize', 'n', 'r', 'k', '<C-w>%s')", curwin == target1 ? "+" : "-")
@tyru
tyru / zero.vim
Created July 22, 2010 17:30 — forked from mattn/zero.vim
" http://d.hatena.ne.jp/os0x/20081115/1226770265
echo len(substitute(join(range(1001)), '[^0]', '', 'g'))