Skip to content

Instantly share code, notes, and snippets.

View komamitsu's full-sized avatar

Mitsunori Komatsu komamitsu

View GitHub Profile
[io.airlit.sample.Main.main()]
- Bootstrap app = new Bootstrap(
new NodeModule(),
new DiscoveryModule(),
new HttpServerModule(),
new JsonModule(),
new JaxrsModule(),
new MBeanModule(),
new JmxModule(),
new JmxHttpModule(),
@komamitsu
komamitsu / Destructive_substitution.ml
Created March 11, 2014 16:48
Destructive Substitution
module type Addable = sig
type t
val add: t -> t -> t
end;;
module type Pair_inf = sig
type t
type endpoint
val create: endpoint -> endpoint -> t
end;;
Map<String, Object> map = new HashMap<>();
map.put("name", "komamitsu");
map.put("age", 39);
ObjectMapper objectMapper = new ObjectMapper();
String serialized = objectMapper.writeValueAsString(map);
System.out.println(serialized);
Map<String, Object> deserialized =
objectMapper.readValue(serialized, new TypeReference<Map<String, Object>>() { });
System.out.println(deserialized);
@komamitsu
komamitsu / gist:0b8c22da8b2815bf9eb2
Last active August 29, 2015 14:03
jackson-dataformat-msgpack_benchmark
Pojo:
Generator:
http://gyazo.com/7eb78f90605c412bfa8d425332213984.png
Parser:
http://gyazo.com/b9344c89980312c06ee88ebd5a76cf4e.png
@komamitsu
komamitsu / gist:d78249b9a32c3979e94a
Created September 15, 2014 16:12
Practice of First-class module (generate new module)
# module type Bumpable = sig
type t
val bump : t -> t
end;;
module type Bumpable = sig type t val bump : t -> t end
# module Int_bumper = struct
type t = int
let bump n = n + 1
end;;
static class ReentrantReadWriteLockExample {
private int loopNum = 30000;
private int slotNum = 10;
private int writeThreadNum = 5;
private int readThreadNum = 5;
public void examinReentrantReadWriteLock() throws InterruptedException {
final HashMap<Integer, Pair<Integer, Integer>> tbl = new HashMap<>();
for (int slot = 0; slot < slotNum; slot++) {
@komamitsu
komamitsu / pod_trunk_push.log
Last active August 29, 2015 14:07
"pod trunk push" doesn't use repos other than default
[komamitsu@potato td-ios-sdk (master)]$ pod trunk push --verbose TreasureData-iOS-SDK.podspec
Validating podspec
$$$$ Trunk#validate_podspec $$$$
$$$$ Validator.init: ["https://github.com/CocoaPods/Specs.git"] $$$$
/Users/komamitsu/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/cocoapods-trunk-0.3.0/lib/pod/command/trunk.rb:337:in `new'
/Users/komamitsu/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/cocoapods-trunk-0.3.0/lib/pod/command/trunk.rb:337:in `validate_podspec'
/Users/komamitsu/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/cocoapods-trunk-0.3.0/lib/pod/command/trunk.rb:289:in `run'
/Users/komamitsu/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/claide-0.7.0/lib/claide/command.rb:271:in `run'
/Users/komamitsu/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/cocoapods-0.34.2/lib/cocoapods/command.rb:48:in `run'
/Users/komamitsu/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/cocoapods-0.34.2/bin/pod:33:in `<top (required)>'
require 'redis'
class RedisBench
def initialize(count)
@count = count
@r = Redis.new
end
def bench(prepare_items, label, &blk)
@r.flushall
@komamitsu
komamitsu / PackedForward_message_from_irb.log
Last active September 15, 2015 15:19
Fluentd:PackedForward format
irb(main):027:0> c = TCPSocket.new('127.0.0.1', 24225) => #<TCPSocket:fd 15>
irb(main):028:0> c.write(MessagePack.pack(['foo.bar', MessagePack.pack([Time.now.to_i, {:name => 'aaa', :age => 12}]) + MessagePack.pack([Time.now.to_i, {:name => 'bbb', :age => 34}])]))
=> 54
>>>
2015-09-16 00:16:28 +0900 foo.bar: {"name":"aaa","age":12}
2015-09-16 00:16:28 +0900 foo.bar: {"name":"bbb","age":34}
@komamitsu
komamitsu / gist:1698799
Created January 29, 2012 13:23
OCaml merge sort
let split_rev cut xs =
let (_, f, s) =
List.fold_left
(fun (i, f, s) x ->
if i < cut then (i + 1, x::f, s) else (i + 1, f, x::s))
(0, [], []) xs
in
(f, s)
let rec ms xs =