Skip to content

Instantly share code, notes, and snippets.

## 材料
パスタ1〜2人前
にんにく1〜2かけ(好みで)
唐辛子1つ
## 調味料
@osyo-manga
osyo-manga / gist-file0.txt
Last active October 7, 2015 09:47
toriniku
## 材料
米2〜3合
鶏もも肉1枚(切ってない奴
## 調味料
醤油(大さじ2杯弱)
塩(大さじ1杯)
酒(大さじ2杯)
@osyo-manga
osyo-manga / main.rb
Created October 5, 2015 16:29
aaaaaaaaaaa
class X
def self.method_added name
p "method_added : #{name}"
prepend(Module.new do
eval <<EOS
def #{name}
p "homu"
super
end
EOS
module MethodAdded
def method_added name
p "method_added : #{name}"
alias_method :homu, name
super name
end
def self.prepended(klass)
klass.extend self
end
class X
def self.method_added name
return if @flag
@flag = true
p "method_added : #{name}"
alias_method "#{name}_impl", name
define_method(name){
send "#{name}_impl"
}
@flag = false
@osyo-manga
osyo-manga / main.rb
Created July 26, 2015 07:26
static typing
module StaticTyping
def method_missing name, *types, &block
define_method(name){ |*args|
if types == args.map(&:class)
block.call *args
else
throw "No match argument types."
end
}
end
" デフォルトでは結合文字の左右に " " をつける
" 入力がなかった場合はスペースを挿入しないで結合する
" , で結合する場合は ", " で結合する
let g:jplus#input_config = {
\ "__DEFAULT__" : {
\ "delimiter_format" : " %d "
\ },
\ "__EMPTY__" : {
\ "delimiter_format" : "%d"
\ },
class FileParser
def parse name
"Failed"
end
end
module ParserCPP
def parse name
if name =~ /\.cpp$/
"C++ file"
class X
def my_to_s
"X"
end
end
class Object
def to_callable to, from = :call
obj = self
@osyo-manga
osyo-manga / main.rb
Created July 8, 2015 11:50
custom puts
module Output
def puts output
if output.class == Person
super output.to_o
else
super output
end
end
end