MessagePackが文字列とバイナリをわけないのは問題?
Objective Cの実装使ってるとある問題にぶちあたった.なので,文字列をちゃんとバイナリ(Raw)と分けるべき,という提案
(*) 俺は熟読したわけではないので,中身が気になる人はちゃんと本スレを読みましょう
LIMIT = {} | |
def limit n | |
key = [caller,Thread.current] | |
LIMIT[key] ||= n | |
LIMIT[key] -= 1 | |
n = LIMIT[key] | |
if n > 0 | |
n | |
else | |
LIMIT.delete key |
# -*- coding: utf-8 -*- | |
class Retry | |
def initialize(times, begin_block) | |
@times = times | |
@begin_block = begin_block | |
end | |
def catch(error_type, &rescue_block) | |
tries = 0 | |
begin | |
@begin_block.call(tries) |
puts 1 | |
puts %w(hello world) * ' ' | |
puts %w(h l t).join('igh') |
MessagePackが文字列とバイナリをわけないのは問題?
Objective Cの実装使ってるとある問題にぶちあたった.なので,文字列をちゃんとバイナリ(Raw)と分けるべき,という提案
(*) 俺は熟読したわけではないので,中身が気になる人はちゃんと本スレを読みましょう
#!/usr/bin/env escript | |
main([Query|_]) -> | |
case matcher(Query) of | |
{ok, Matcher} -> | |
print(lists:filter(Matcher, http_statuses())); | |
{error, {Message, Position}} -> | |
io:format("Error: ~s at ~p character~n", [Message, Position]) | |
end; |
サイズがあまりに大きくなってしまったので、gist ではなくて github 上で管理するようにしました。
https://github.com/Shinpeim/process-book
URL 変わっちゃうの申し訳ないんだけど、一覧性が高くなるのと pull req が受け取れるメリットのほうを取ります。せっかく読みにきてくれたのにひと手間かかっちゃってすみません。
# config/initializers/i18n_exception_handler.rb | |
I18n.exception_handler = ->(exception, locale, key, options) do | |
if exception.is_a?(I18n::MissingTranslation) | |
Rails.logger.warn exception.message if Rails.env.development? | |
key.to_s.split('.').last.humanize | |
else | |
raise exception | |
end | |
end |
# coding: utf-8 | |
class MPQueue | |
def initialize | |
@wcout,@wcin = IO.pipe # lock for write | |
@rcout,@rcin = IO.pipe # lock for read | |
@lout,@lin = IO.pipe | |
@dout,@din = IO.pipe |