Skip to content

Instantly share code, notes, and snippets.

View kana's full-sized avatar

Kana Natsuno kana

View GitHub Profile
" perl: add 'use' statement for package name under the cursor
function! AddUse()
let line = line('.')
let col = col('.')
normal! yiw
let default = @0
let package = input('Package? ', default)
if (search('^use\s\+'.package, 'bnw') == 0)
call search('^use\s\+', 'b')
put ='use ' . package . ';'
3,5c3,5
< Fuji
< Taka
< Nasubi
---
> 1 Fuji
> 2 Taka
> 3 Nasubi
7,9c7,9
< Sen
@kana
kana / date.hs
Created February 6, 2011 12:06
Reviewing Haskell by writing Unix commands
import System.Time
import System.Locale
main = getClockTime >>=
toCalendarTime >>=
putStrLn . formatCalendarTime defaultTimeLocale "%c"
data ShellState = ShellState {
count :: Int
}
main = do
ls <- getContents
s <- return $ ShellState 0
static class ComposingTest
{
static private bool Not(bool x)
{
return !x;
}
static private bool Even(int x)
{
return x % 2 == 0;
@kana
kana / a-snippet-from-my-keyboard.ini
Created April 29, 2011 04:23
N-stroke keyboard shortcuts that I've used since Opera 6
Platform Mac, w meta, c = Close page, 1
Platform Mac, w meta, c meta = Close page, 1
Platform Mac, w meta, j = Focus page
Platform Mac, w meta, j meta = Focus page
Platform Mac, w meta, k = Focus address field | Focus message list
Platform Mac, w meta, k meta = Focus address field | Focus message list
Platform Mac, w meta, n = New page, 1
Platform Mac, w meta, n meta = New page, 1
Platform Mac, w meta, s = Duplicate page
Platform Mac, w meta, s meta = Duplicate page
require 'rake'
require 'watchr'
file 'foo' => ['bar', 'baz'] do
sh 'cat bar baz >foo'
end
if self.instance_of? Watchr::Script::EvalContext then
watch /^(bar|baz)$/ do
sh 'rake -f rake_and_watchr.rb foo'
file ',README.html' => 'README.html' do
sh 'sha1sum README.html >,README.html'
end
file 'README.html' => 'README.asciidoc' do
sh 'asciidoc -b xhtml11 README.asciidoc'
end
__END__
@kana
kana / gist:955336
Created May 4, 2011 14:46
Strange behavior of Ruby Dir.glob on Mac OS X 10.5
$ uname
Darwin
$ mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local)
fdesc on /dev (fdesc, union)
map -hosts on /net (autofs, automounted)
map auto_home on /home (autofs, automounted)
--- s.vim.before 2011-05-14 14:12:34.000000000 +0900
+++ s.vim.after 2011-05-14 14:12:27.000000000 +0900
@@ -21,7 +21,6 @@
" Basic {{{
-"set no compatible
set nocompatible
"reset