Skip to content

Instantly share code, notes, and snippets.

View rummelonp's full-sized avatar
🐈‍⬛
ニャーン

Kazuya Takeshima rummelonp

🐈‍⬛
ニャーン
View GitHub Profile
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
@Shinpeim
Shinpeim / retry.rb
Last active December 14, 2015 06:48
# -*- 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)
@takkkun
takkkun / example.rb
Last active December 14, 2015 04:29
puts 1
puts %w(hello world) * ' '
puts %w(h l t).join('igh')
@repeatedly
repeatedly / msgpack_issue_121.md
Last active November 30, 2021 02:09
MessagePackが文字列とバイナリをわけないのは問題?

MessagePackが文字列とバイナリをわけないのは問題?

msgpack/msgpack#121

Objective Cの実装使ってるとある問題にぶちあたった.なので,文字列をちゃんとバイナリ(Raw)と分けるべき,という提案

(*) 俺は熟読したわけではないので,中身が気になる人はちゃんと本スレを読みましょう

そもそもMessagePackとは

#!/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;
@Shinpeim
Shinpeim / 000.md
Last active November 2, 2024 00:52
プロセスとかスレッドとかプロセス間通信とかについて書く場所

重要

サイズがあまりに大きくなってしまったので、gist ではなくて github 上で管理するようにしました。

https://github.com/Shinpeim/process-book

URL 変わっちゃうの申し訳ないんだけど、一覧性が高くなるのと pull req が受け取れるメリットのほうを取ります。せっかく読みにきてくれたのにひと手間かかっちゃってすみません。

この文書の目的

@tkawa
tkawa / i18n_exception_handler.rb
Created February 3, 2013 12:36
Railsでlocaleの翻訳が見つからなかったとき、“translation missing”はログに出して、viewにはhumanizeした文字列を出す
# 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
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 1, 2025 01:48
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@clicube
clicube / mpqueue.rb
Created January 15, 2013 07:54
queue for multi processing
# 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
@zenorocha
zenorocha / README.md
Last active February 10, 2025 07:42
A template for Github READMEs (Markdown) + Sublime Snippet

Project Name

TODO: Write a project description

Installation

TODO: Describe the installation process

Usage