Skip to content

Instantly share code, notes, and snippets.

@t9md
t9md / scratch.py
Created October 31, 2010 11:58
python decorator example
#!/usr/bin/env python
# -*- coding: utf8 -*-
############################################
## Setup
############################################
# function which return newley created function
def gen_seq_transformer(f):
"""
Take trans function as argment
@t9md
t9md / scratch.vim
Created October 31, 2010 14:48
vim_bridge example try
echo "-----------------------------------------------"
echo "Self training for 'vim_vridge' example"
echo " http://github.com/nvie/vim_bridge/tree/master/examples/"
echo "-----------------------------------------------"
echo "Example 1"
echo "-----------------------------------------------"
python << ENDPYTHON
from vim_bridge import bridged
@bridged
@t9md
t9md / scratch.vim
Created November 5, 2010 02:48
execute shell command on iTerm window from MacVim via rb-appscript
ruby << ENDRUBY
require 'rubygems'
require 'appscript'
include Appscript
class ITerm
class << self
def activate;
@iterm ||= app('iTerm')
@t9md
t9md / scratch.vim
Created November 5, 2010 03:02
manupilate iTerm from Vim (short version)
ruby << ENDRUBY
require 'rubygems'
require 'appscript'
ENDRUBY
fun! ITermWrite(cmd)
ruby Appscript.app('iTerm').current_terminal.sessions.write(:text => VIM::evaluate('a:cmd'))
endfun
command! -nargs=? RakeOnIterm :call ITermWrite("rake " .<q-args>)
@t9md
t9md / sample.rb
Created November 13, 2010 02:23
iTerminitor sample config
window :name => "win1 tab1", :win_bounds => {:side => 0, :top => 0, :width => 500, :height => 500 } do
run "echo 'win1 tab1'"
tab :name => "tab2", :session => "Default Session" do
# run_file でファイルからコマンドリストを読み込む事も可能。
run_file "~/.iterminitor/run_file_example"
run 'echo tab2'
end
# You can specify bookmarked session name for ':session' option
#!/bin/bash
export LANG=C
for service in $(/sbin/chkconfig --list | grep 3:on | awk '{ print $1 }')
do
while :
do
echo -n "disable $service ?: "
read answer
case $answer in
Y|y)
@t9md
t9md / vps_create.sh
Created December 19, 2010 03:51
OpenVZ private PtoP network VPS
#!/bin/bash
VPSID=$1IPADDR=$2
HOSTNAME=$3help(){
echo "$(basename $0) 'VPSID' 'IPADDR' 'HOSTNAME'" echo "ex) $(basename $0) 1001 192.168.3.1 vps01"}
if [ $# -ne 3 ];then
help
exit 1
fi
vzlist ${VPSID} >/dev/null 2>&1
echo -e "let g:vimrc_local_finish = 1\nset langmenu=ja_ja.utf-8.macvim" > /Applications/MacVim.app/Contents/Resources/vim/vimrc_local.vim
echo "let g:gvimrc_local_finish = 1" > /Applications/MacVim.app/Contents/Resources/vim/gvimrc_local.vim
@t9md
t9md / wmctrl.rb
Created February 26, 2011 16:16
wrapper script for me in Ubuntu marveric
#!/usr/bin/env ruby
# DIRECTION=ARGV[0]
# A move and resize argument has the format 'g,x,y,w,h'. All five
# components are integers. The first value, g, is the gravity of
# the window, with 0 being the most common value (the default
# value for the window). Please see the EWMH specification for
# other values.
# The four remaining values are a standard geometry specification:
@t9md
t9md / curry.vim
Created March 13, 2011 13:44
vimscript でカリー化
" Utility function"{{{
fun! Echo(e)
echo a:e
endfun
fun! Header(num)
echo "\n" . a:num . "\n"
endfun
command! -nargs=* H :call Header(<f-args>)"}}}
function! Curry(...)"{{{