This file contains 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
let s:S = vital#vital#import('Data.String') | |
let s:L = vital#vital#import('Data.List') | |
function! s:count_words(text) abort | |
let F = { memo, x -> extend(memo, {x: get(memo, x, 0) + 1}) } | |
return s:L.foldl(F, {}, s:S.scan(a:text, '\w\+')) | |
endfunction | |
echo s:count_words('this is a pen or not a pen') | |
" {'this': 1, 'is': 1, 'a': 2, 'pen': 2, ...} |
This file contains 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 | |
if git-rev-parse --verify HEAD >/dev/null 2>&1 | |
then | |
against=HEAD | |
else | |
# Initial commit: diff against an empty tree object | |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
fi |
This file contains 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
Signal.trap(:QUIT) do | |
puts "QUIT signal sent." | |
exit 0 | |
end | |
puts "Signal.list['QUIT'] => #{Signal.list['QUIT']}" | |
puts "My pid is #{$$}\n" | |
loop do | |
puts 'I\'m alive!' |
This file contains 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/syntax/markdown.vim | |
" \c で 大文字小文字無視します :help /\c | |
" todo: TODO: をハイライトしたい | |
syntax match myTodo /\ctodo:/ containedin=ALL | |
" done: DONE: をハイライトしたい | |
syntax match myDone /\cdone:/ containedin=ALL | |
" 適当に色付け | |
highlight link myTodo Todo |
This file contains 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 mkdir("vimdoc-ja/doc", "p") | |
call mkdir("vimdoc-ja/syntax", "p") | |
call rename("help_ja.vim","vimdoc-ja/syntax/help_ja.vim") | |
for s:file in split(glob('*.jax'), "\n") | |
call rename(s:file, "vimdoc-ja/doc/" . s:file) | |
endfor |
This file contains 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
vnew | |
setlocal bufhidden=hide buftype=nofile noswapfile nobuflisted | |
let s:doyagao = {'counter': 0, 'save_updatetime': &updatetime, 'bufnr': bufnr('%')} | |
function! s:doyagao.funcall() dict | |
if self.bufnr !=# bufnr('%') | |
call self.clear() | |
return |
This file contains 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
" <Space><C-n>, <Space><C-p>: Move window position {{{ | |
nnoremap <silent> <Space><C-n> :<C-u> call <SID>swap_window(v:count1)<CR> | |
nnoremap <silent> <Space><C-p> :<C-u> call <SID>swap_window(-v:count1)<CR> | |
function! s:modulo(n, m) "{{{ | |
let d = a:n * a:m < 0 ? 1 : 0 | |
return a:n + (-(a:n + (0 < a:m ? d : -d)) / a:m + d) * a:m | |
endfunction "}}} | |
function! s:swap_window(n) "{{{ |
This file contains 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! s:uniq(list) "{{{ | |
let s:dict = {} | |
let counter = 1 | |
for i in a:list | |
if !has_key(s:dict, i) | |
let s:dict[i] = counter | |
let counter += 1 | |
endif | |
endfor |
This file contains 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! s:ParseMarkdown() | |
return map(split(join(getline(1, '$'), "\n"), '\v(^|\n)\ze#+'), 'split(v:val, "\n")') | |
endfunction | |
" Usage | |
let s:pages = s:ParseMarkdown() | |
let s:max_page_number = len(s:pages) - 1 |
This file contains 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
"============================================================================= | |
" FILE: poslist.vim | |
" AUTHOR: Shougo Matsushita <Shougo.Matsu@gmail.com> | |
" MODIFIED BY: thinca <thinca@gmail.com> | |
" Last Modified: 23 Jan 2010 | |
" Usage: Just source this file. | |
" License: MIT license {{{ | |
" Permission is hereby granted, free of charge, to any person obtaining | |
" a copy of this software and associated documentation files (the | |
" "Software"), to deal in the Software without restriction, including |
NewerOlder