Skip to content

Instantly share code, notes, and snippets.

View kyuden's full-sized avatar

Masahiro Kyuden kyuden

View GitHub Profile
class ProducerConsumer
KILL = :kill
def initialize(produce:, consume:, producer_num: 1, consumer_num: 5, max_queue_size: 1000)
@produce = produce
@consume = consume
@consumer_num = consumer_num
@producer_num = producer_num
@ids_index = 0
@max_queue_size = max_queue_size
# バックナンバー
### Rubyわくわくナビ
- 2012-66:Bundlerを使いこなす!
- 2012-67:厳選!用途別Ruby/Railsライブラリツール
- 2012-68:データで見るRubyGemsの世界
### 一歩先をゆくRuby
504b 0304 1400 0000 0000 ed60 3a48 615b
d117 3e03 0000 3e03 0000 1600 0000 436f
6d6d 656e 7473 2e74 6d50 7265 6665 7265
6e63 6573 3c3f 786d 6c20 7665 7273 696f
6e3d 2231 2e30 2220 656e 636f 6469 6e67
3d22 5554 462d 3822 3f3e 0a3c 2144 4f43
5459 5045 2070 6c69 7374 2050 5542 4c49
4320 222d 2f2f 4170 706c 6520 436f 6d70
7574 6572 2f2f 4454 4420 504c 4953 5420
312e 302f 2f45 4e22 2022 6874 7470 3a2f
@kyuden
kyuden / install_jman.sh
Created June 11, 2016 17:38 — forked from ay65535/install_jman.sh
日本語manページをインストールするスクリプト (Mac用,というか自分用)
#!/usr/bin/env bash
# 参考サイト: http://tukaikta.blog135.fc2.com/blog-entry-224.html
# ================各種設定================
# ダウンロードするファイル (GNU 日本語man)
#
# http://linuxjm.sourceforge.jp/ からダウンロードするファイルを指定します。
#export GNUJMAN=man-pages-ja-20120915.tar.gz
#export GNUJMAN=man-pages-ja-20150315.tar.gz
@kyuden
kyuden / typeof.js
Last active October 16, 2015 10:00
社内JS勉強会 : typeof検定
// 環境 node v4.1.2
// 実行せず出力結果を記述しなさい
console.log(typeof 'foo');
console.log(typeof new Object());
console.log(typeof undefined);
console.log(typeof new Function('x', 'y', 'return x * y'));
console.log(typeof true);
console.log(typeof /abc/g);
console.log(typeof String('hoge'));
console.log(typeof 10);
@kyuden
kyuden / unread.md
Created February 15, 2015 11:32
unread 概略構成
@kyuden
kyuden / cattr_accessor_vs_class_attribute
Last active August 29, 2015 14:15
cattr_accessor vs class_attribute
[1] pry(main)> class Base
[1] pry(main)* cattr_accessor :setting2
[1] pry(main)* end
=> [:setting2]
[2] pry(main)> class Subclass < Base ; end
=> nil
[3] pry(main)> Base.setting2
=> nil
[4] pry(main)> Base.setting2 = true
@kyuden
kyuden / gist:654236a100f81d03d22b
Created February 1, 2015 13:57
nilチェック入りeach
(User.hoges || []).each do |hoge|
hoge.fuga!
end
@kyuden
kyuden / mutable_constant.rb
Last active August 29, 2015 14:13
定数フリーズまとめ
class MutableConstant
SERVICE_TYPES1 = ["basic", "premium", "pro"]
SERVICE_TYPES2 = ["basic", "premium", "pro"].freeze
SERVICE_TYPES3 = ["basic", "premium", "pro"].map(&:freeze).freeze
module Defaults
SERVICE_TYPES1 = ["basic", "premium", "pro"]
SERVICE_TYPES2 = ["basic", "premium", "pro"].freeze
SERVICE_TYPES3 = ["basic", "premium", "pro"].map(&:freeze).freeze
end
#!/usr/bin/env ruby
require "webrick"
=begin
WEBrick is a Ruby library that makes it easy to build an HTTP server with Ruby.
It comes with most installations of Ruby by default (it’s part of the standard library),
so you can usually create a basic web/HTTP server with only several lines of code.
The following code creates a generic WEBrick server on the local machine on port 1234,