Skip to content

Instantly share code, notes, and snippets.

View akm's full-sized avatar

Takeshi Akima akm

View GitHub Profile
@akm
akm / file0.js
Created April 15, 2014 12:43
MongoDB-2.6.0で変わったensureIndexの振る舞い ref: http://qiita.com/akm/items/799f2c7a6a6697f25127
% mongo test
MongoDB shell version: 2.4.6
connecting to: test
>
> db.t1.drop();
false
> db.createCollection("t1", {});
{ "ok" : 1 }
> db.t1.ensureIndex({f1: 1}, {uniq: true});
> db.t1.ensureIndex({f1: 1}, {});
@akm
akm / file0.txt
Created April 16, 2014 05:05
MongoDB-2.6.0で変わったmongoexportの出力 ref: http://qiita.com/akm/items/528428dc5bc848a3963c
% mongo test --eval "db.d1.drop(); db.d1.insert({no: 1, d: new Date()})" && mongoexport -d test -c d1
MongoDB shell version: 2.4.6
connecting to: test
connected to: 127.0.0.1
{ "_id" : { "$oid" : "534e0af8532dbdbaa7c05783" }, "no" : 1, "d" : { "$date" : 1397623544193 } }
exported 1 records
@akm
akm / file0.txt
Created June 16, 2014 10:31
Mavericksでerlang R15B01をインストールする方法 ref: http://qiita.com/akm/items/bf14253a27943b13e79b
kerl build R15B01 r15b01-01
@akm
akm / file0.txt
Created June 30, 2014 15:00
7つのデータベース7つの世界 第3章Riak2日目のハマりどころ ref: http://qiita.com/akm/items/d33472936f6fccf6b26b
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.9.3
BuildVersion: 13D65
-module(recursive).
-export([split/2]).
-export([fib/1]).
split(D, L) -> split(D, L, [], []).
split(_, [] , R, W) -> [lists:reverse(X) || X <- lists:reverse([W|R])];
split(D, [D|T], R, W) -> split(D, T, [W|R], []);
split(D, [H|T], R, W) -> split(D, T, R, [H|W]).
fib(0) -> 0;
@akm
akm / sq_escape.rb
Created February 27, 2015 07:44
single quote escape for bash
def sq_escape(str)
str.split(/\'/).map{|s| "'#{s}'"}.join("\\'")
end
sq_escape {"breakfast"=>"Bill's"}.to_json
#=> "'{\"breakfast\":\"Bill'\\''s\"}'"
puts sq_escape {"breakfast"=>"Bill's"}.to_json
#=> '{"breakfast":"Bill'\''s"}'
# # on bash
# $ echo '{"breakfast":"Bill'\''s"}'
@akm
akm / remote_manifesto.ja.text
Last active August 29, 2015 14:18
The Remote Manifesto (ja)
The original is https://about.gitlab.com/2015/04/08/the-remote-manifesto/
We all have been greatly helped by Scrum and the Agile manifesto.
It freed us from waterfall planning and excessive process. But working
remotely and continuous delivery need something more.
私達は皆Scrumとアジャイルマニフェストに救われてきました。
それはウォーターフォールの計画ややり過ぎたのプロセスから私達を開放してくれました。
しかし、リモートでの働き方や継続的デリバリにはまだ何か必要なのです。
@akm
akm / gist:9362
Created September 8, 2008 02:21 — forked from taka2/gist:9290
require 'java'
require 'poi-3.1-FINAL-20080629.jar'
class RubyOutputStream < java.io.OutputStream
def set_io(io)
@io = io
end
def write(b)
if b.is_a?(Fixnum)
@akm
akm / gist:9360
Created September 8, 2008 02:19 — forked from taka2/gist:9289
require 'java'
require 'poi-3.1-FINAL-20080629.jar'
java.io.FileOutputStream.new("test2.xls") do |io|
wb = org.apache.poi.hssf.usermodel.HSSFWorkbook.new
wb.createSheet("First")
wb.write(io)
end
@akm
akm / tree_ancestors method
Created September 21, 2008 07:18
tree_ancestors method
class Module
def tree_ancestors
puts_tree_acestors(0, [self])
end
protected
def puts_tree_acestors(indent, displayed_modules)
puts "%s[%s] %s" % [' ' * indent, (self.is_a?(Class) ? 'C' : 'M'), self.name]
nested_included_modules = included_modules.map{|mod| mod.included_modules}.uniq.flatten # - displayed_modules
my_included_modules = included_modules - nested_included_modules