Skip to content

Instantly share code, notes, and snippets.

@cohama
cohama / .zshrc
Created November 20, 2013 16:07
スペース2回で "git " を入力する
function do_space() {
if [ "$BUFFER" = " " ]; then
LBUFFER="git "
else
LBUFFER="$LBUFFER "
fi
}
zle -N do_space
bindkey ' ' do_space
@cohama
cohama / .zshrc
Created November 6, 2013 10:14
Enter 単発で `ls` を実行。1つのスペース+Enter で `git staus -s` を実行
function do_enter() {
if [ -z "$BUFFER" ]; then
echo
ls -F
elif [ "$BUFFER" = " " ]; then
if [ "$(git rev-parse --is-inside-work-tree 2> /dev/null)" = 'true' ]; then
echo
echo -e "\e[0;33m--- git status ---\e[0m"
git status -s
fi
@cohama
cohama / simple_lambda.ml
Last active December 23, 2015 02:49
TaPL 10 章 単純型付きラムダ計算の実装
let (|>) x f = f x
let (|-) f g = fun x -> g (f x)
let getOrElse defVal = function
| Some(v) -> v
| None -> defVal
type ty =
| TyArr of ty * ty (* arrow type *)
| TyBool
foldl' :: (a -> b -> a) -> a -> [b] -> a
foldl' f acc [] = acc
foldl' f acc (x:xs) = foldl' f (f acc x) xs
foldr' :: (a -> b -> b) -> b -> [a] -> b
foldr' f acc [] = acc
foldr' f acc (x:xs) = f x (foldr' f acc xs)
@cohama
cohama / scheme.vim
Created August 8, 2013 15:46
Scheme でも lisp_rainbow! .vim/after/syntax/scheme.vim に配置
syn region schemeParen0 matchgroup=hlLevel0 start="`\=(" end=")" skip="|.\{-}|" contains=ALLBUT,schemeParen0,schemeParen2,schemeParen3,schemeParen4,schemeParen5,schemeParen6,schemeParen7,schemeParen8,schemeParen9
syn region schemeParen1 contained matchgroup=hlLevel1 start="`\=(" end=")" skip="|.\{-}|" contains=ALLBUT,schemeParen1,schemeParen3,schemeParen4,schemeParen5,schemeParen6,schemeParen7,schemeParen8,schemeParen9,schemeParen0
syn region schemeParen2 contained matchgroup=hlLevel2 start="`\=(" end=")" skip="|.\{-}|" contains=ALLBUT,schemeParen2,schemeParen4,schemeParen5,schemeParen6,schemeParen7,schemeParen8,schemeParen9,schemeParen0,schemeParen1
syn region schemeParen3 contained matchgroup=hlLevel3 start="`\=(" end=")" skip="|.\{-}|" contains=ALLBUT,schemeParen3,schemeParen5,schemeParen6,schemeParen7,schemeParen8,schemeParen9,schemeParen0,schemeParen1,schemeParen2
syn region schemeParen4 contained matchgroup=hlLevel4 start="`\=(" end=")" skip="|.\{-}|" contains=ALLBUT,schemeParen4,schemeParen6,
diff -r c8559a2d8e5f runtime/ftplugin/ocaml.vim
--- a/runtime/ftplugin/ocaml.vim Sun Jul 21 17:06:00 2013 +0200
+++ b/runtime/ftplugin/ocaml.vim Mon Jul 22 00:34:09 2013 +0900
@@ -44,19 +44,21 @@
" (un)commenting
if !hasmapto('<Plug>Comment')
nmap <buffer> <LocalLeader>c <Plug>LUncomOn
- vmap <buffer> <LocalLeader>c <Plug>BUncomOn
+ xmap <buffer> <LocalLeader>c <Plug>BUncomOn
nmap <buffer> <LocalLeader>C <Plug>LUncomOff
fn :: [String] -> Int -> String
fn ~(h:t) n = if n == 0
then "oops."
else h ++ ":" ++ show t
main :: IO ()
main = putStrLn $ fn [] 0
@cohama
cohama / hoge.hs
Created June 23, 2013 13:18
SEND_MORE_MONEY in Haskell
-- S E N D
-- + M O R E
-- ---------
-- M O N E Y
import Data.List
digitsToNum :: [Int] => Int
digitsToNum = foldl (\acc x -> 10*acc + x) 0
let s:V = vital#of('vital')
let s:S = s:V.import('Data.String')
let start = reltime()
let test1 = s:S.substitute_last(repeat('vim is vital', 1000), 'i', 'ooo')
let elapsed = reltimestr(reltime(start))
echo "substitute last" elapsed
let start = reltime()
let test2 = substitute(repeat('vim is vital', 1000), 'i', 'ooo', '')
let elapsed = reltimestr(reltime(start))
if has('vim_starting')
set runtimepath+=~/tmp/bundle/neobundle.vim/
endif
call neobundle#rc(expand('~/tmp/bundle/'))
NeoBundleLazy 'Shougo/vimfiler', {
\ 'autoload' : {
\ 'commands' : ['VimFiler'],
\ }}