Skip to content

Instantly share code, notes, and snippets.

@soplana
soplana / gist:5821515
Created June 20, 2013 09:40
mongo consoleで6/20 ~ 21日のnginxアクセスログを集計
db.nginx_access.group(
{
key: {url: true},
cond: {time: {
$gte: ISODate("2013-06-20T00:00:00Z"),
$lte: ISODate("2013-06-21T00:00:00Z")}
},
initial: {count: 0},
reduce: function(doc, out){out.count++}
}
@soplana
soplana / gist:5409258
Last active December 16, 2015 08:58
特定のインスタンスにだけメソッドチェインを追加したい
class Hoge
end
@hoge = Hoge.new
@hoge.instance_eval do
def fuga
fuga = Struct.new("Fuga", :piyo)
piyo = Struct.new("Piyo", :udon)
fuga.new(piyo.new("mogumogu"))
@soplana
soplana / gist:5362079
Last active December 16, 2015 02:19
キモいコード
class Hello
  def say &block
    self.instance_eval &block
  end

  def say_hello
    "hello!!"
  end
end
send_data( @history.to_image, :disposition => "inline", :type => "image/png" )
@soplana
soplana / gist:2464249
Created April 22, 2012 14:03 — forked from thash/gist:2139402
Leeno API
@soplana
soplana / gist:2464248
Created April 22, 2012 14:02 — forked from thash/gist:2139402
Leeno API