Skip to content

Instantly share code, notes, and snippets.

(defun autoload-if-found (function file &optional docstring interactive type)
"set autoload if. FILE has found."
(and (locate-library file)
(autoload function file docstring interactive type)))
@t9md
t9md / eliminate_ANSI_ESCAPE_for_terminal_table.rb
Created October 14, 2010 07:48
eliminate ANSI_ESCAPE for terminal-table
require 'rubygems'
require 'colored'
require 'terminal-table/import'
class String
alias_method :to_s_orig, :to_s
def to_s
str = self.to_s_orig
if ::ELIMINATE_ANSI_ESCAPE
str = str.sub(/^\e\[[\[\e0-9;m]+m/, "")
@t9md
t9md / OOP String.vim
Created October 17, 2010 19:43
VimScript experiment(JavaScript Like OOP)
" method:
"============================================================
let s:m = {}
fun! s:m.capitalize()
return substitute(self.data,'^\(.\)','\u\1',"")
endfun
fun! s:m.upcase()
return toupper(self.data)
endfun
@t9md
t9md / copy_and_move_text.vim
Created October 24, 2010 13:08
Copy and Move text easily in vim
fun! MoveSelectedText(direction) range
if a:direction == 'j'
let cmd = a:firstline . ",". a:lastline . "move " . (a:lastline + 1)
elseif a:direction == 'k'
let cmd = a:firstline. ",". a:lastline . "move " . (a:firstline - 2)
elseif a:direction == 'l'
let cmd = "normal gv>>"
elseif a:direction == 'h'
let cmd = "normal gv<<"
endif
./configure --enable-rubyinterp --with-macsdk=10.5 --with-features=huge --enable-perlinterp --enable-pythoninterp --enable-tclinterp
vim src/auto/config.mk
RUBY_SRC = if_ruby.c
RUBY_OBJ = objects/if_ruby.o
RUBY_PRO = if_ruby.pro
RUBY_CFLAGS = -I/Users/maeda_taku/.rvm/src/ruby-1.8.7-p302
RUBY_LIBS = -lruby-static -lpthread -ldl -lobjc -L/Users/maeda_taku/.rvm/rubies/ruby-1.8.7-p302/lib
@t9md
t9md / tranparency_to.rb
Created October 28, 2010 08:06
set iTerm transparency via command
#!/usr/bin/env ruby
require 'rubygems'
require 'appscript'
num = ARGV[0]
unless num
puts " #{File.basename($0)} 0-10"
exit 2
end
@t9md
t9md / scratch.rb
Created October 29, 2010 09:48
register particular method used as command
#!/usr/bin/env ruby
module Kernel
private
def this_method
caller[0][/`([^']*)'/, 1]
end
def calling_method
caller[1][/`([^']*)'/, 1]
@t9md
t9md / scratch.vim
Created October 29, 2010 11:42
Interchange variable between python and vim
"===========================================
" help Python
"===========================================
" vim.eval(str) *python-eval*
" Evaluates the expression str using the vim internal expression
" evaluator (see |expression|). Returns the expression result as:
" - a string if the Vim expression evaluates to a string or number
" - a list if the Vim expression evaluates to a Vim list
" - a dictionary if the Vim expression evaluates to a Vim dictionary
" Dictionaries and lists are recursively expanded.
@t9md
t9md / scratch.py
Created October 30, 2010 07:26
python's class attribute and function attribute named method
#!/usr/bin/env python
# -*- coding: utf8 -*-
# クラス
class Spam(object):
"""docstring for Spam"""
# クラス属性
class_atrr = "This is class attribute"
@t9md
t9md / pyvim_anything_like.py
Created October 30, 2010 17:31
emacs's anything like command launcher
# -*- coding: utf8 -*-
import vim
import sys
import re
import os
def normal(str):
vim.command("normal! "+str)
def select_all_buffer():