Skip to content

Instantly share code, notes, and snippets.

View tagomoris's full-sized avatar

Satoshi Tagomori tagomoris

View GitHub Profile
module HookPoints; end
using HookPoints
require 'super_storage_x'
class Target
def testing_method
SuperStorageX.store("x")
end
end
class Foo
def self.foo
"foo"
end
def foo
"ifoo"
end
end
module Interceptor
class Foo
def self.foo
"foo"
end
def foo
"ifoo"
end
def true_foo
Foo.foo
end
class Foo
def self.foo
"foo"
end
def foo
"ifoo"
end
def true_foo
Foo.foo
end
class A
end
class B < A
end
A.define_singleton_method(:foo){ "foo" }
A.foo #=> "foo"
B.foo # NoMethodError
@tagomoris
tagomoris / gist:a173bb6317ddc55dcfb3
Created May 11, 2014 10:00
jruby occurs segmentation fault with command line argument including '%d' and '%S'
$ jruby -e 'p ARGV' '%Y%m%d'
["%Y%m%d"]
$ jruby -e 'p ARGV' '%Y%m%d%H'
["%Y%m%d%H"]
$ jruby -e 'p ARGV' '%Y%m%d%H%M'
["%Y%m%d%H%M"]
$ jruby -e 'p ARGV' '%Y%m%d%H%M%S'
Segmentation fault: 11
$ jruby -e 'p ARGV' '%S'
["%S"]
@tagomoris
tagomoris / ASTLibFunctionHelper.java
Last active August 29, 2015 14:01
esper-5.0 may contain BUG to recognize functions case-sensitive
// line 302
boolean filtered = childNodeText.startsWith("f");
if (childNodeText.equals("min") || childNodeText.equals("fmin")) { //toLowerCase().equals("min")
minMaxTypeEnum = MinMaxTypeEnum.MIN;
}
else if (childNodeText.equals("max") || childNodeText.equals("fmax")) {
minMaxTypeEnum = MinMaxTypeEnum.MAX;
}
else {
throw ASTWalkException.from("Uncountered unrecognized min or max node '" + ident + "'");
var crypto = require('crypto');
var passphrase = new Buffer("xxxxx");
var data = "secret data to protect";
var cipher = crypto.createCipher('aes192', passphrase);
cipher.update(data, 'utf8');
var result_buf = cipher.final(); //=> SlowBuffer

Recipes

ざっと見るよ!

Pivot

テーブルをピボットあるいは転置するのはレポーティングや可視化で頻出なのでやっとこうね。普通SQLでは複数フィールドでのgroupingで実現する。 が、2次元のみを扱い、特にそのうちの1次元がごく少数の候補のみによって構成される場合、その候補すべてをカラムに展開してしまうのが便利な場合があるよ。

たとえば長い順に100単語をシェイクスピアの戯曲から見付けたい場合。各々の作品中で何度ずつ出てきたかもいっしょにカウントする。