Skip to content

Instantly share code, notes, and snippets.

View mdaisuke's full-sized avatar
:octocat:
write code

mdaisuke mdaisuke

:octocat:
write code
View GitHub Profile
class Sample
attr_accessor :method
def initialize
@method = :get
end
def self.get
new.perform
end
def perform
send("perform_#{method}")
@mdaisuke
mdaisuke / setup_vim.sh
Created October 29, 2010 15:45
setting up vim plugins
mkdir ~/.vim
cd ~/.vim/
git clone http://github.com/tpope/vim-pathogen.git
# need following in .vimrc
# call pathogen#runtime_append_all_bundles()
mv ./vim-pathogen/* ./
rm -rf ./vim-pathogen/
mkdir ~/.vim/bundle
cd ~/.vim/bundle
git clone http://github.com/Shougo/vimproc.git
@mdaisuke
mdaisuke / with_header
Created December 17, 2010 10:22
add_header_to_array
class Array
def with_header(header)
Hash[*header.zip(self).flatten]
end
end
@mdaisuke
mdaisuke / object_expansion.rb
Created February 10, 2011 07:40
object expansion
module YMD
def year
self.split("-")[0]
end
def month
self.split("-")[1]
end
def day
self.split("-")[2]
end
@mdaisuke
mdaisuke / get_request_token.rb
Created February 13, 2011 06:37
get_request_token.rb
require 'openssl'
require 'uri'
require 'net/http'
require 'yaml'
require 'pp'
def random_str
a = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
(Array.new(16){a[rand(a.size)]}).join
end
require 'openssl'
require 'uri'
require 'net/http'
require 'yaml'
require 'pp'
app_info = YAML.load_file 'consumer_info.yml'
CONSUMER_KEY = app_info['consumer_key']
CONSUMER_SECRET = app_info['consumer_secret']
OAUTH_TOKEN = app_info['oauth_token']
@mdaisuke
mdaisuke / part.vimrc
Created February 14, 2011 02:27
vimrc for pathogen
call pathogen#runtime_append_all_bundles()
@mdaisuke
mdaisuke / ssh_config
Created February 16, 2011 02:05
ssh tonel :)
Host gate.com
ForwardAgent yes
IdentityFile ~/.ssh/id_rsa
User test
Host host
ForwardAgent yes
IdentityFile ~/.ssh/id_rsa
ProxyCommand ssh -A gate.com nc -w 10 %h %p
@mdaisuke
mdaisuke / gitconfig
Created February 16, 2011 02:06
~/.gitconfig
[user]
name = username
email = emailaddress
[core]
editor = vim
[color]
ui = true
[alias]
st = status
co = checkout
@mdaisuke
mdaisuke / bash_profile
Created February 16, 2011 02:06
bash profile to read bashrc
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
export LANG=ja_JP.UTF-8