Skip to content

Instantly share code, notes, and snippets.

@hiroeorz
hiroeorz / file0.txt
Created May 4, 2014 09:20
ツナでもわかるmruby [3回目:数値] ref: http://qiita.com/hiroeorz@github/items/310750f445028179b022
$ mirb
mirb Embeddable Interactive Ruby Shell
>
@hiroeorz
hiroeorz / mirb
Created May 4, 2014 14:11
ツナでもわかるmruby [4回目:バイナリデータフォーマットの実装] ref: http://qiita.com/hiroeorz@github/items/27e0866f493e0e7a65c5
def fixed_header(params)
message_type = params[:message_type] || 1
dup = params[:dup] || 0
qos = params[:qos] || 0
retain = params[:retain] || 0
remaining_size = params[:remaining_size] || 0
data_1 = (message_type << 4) | (dup << 3) | (qos << 1) | retain
data_2 = remaining_size
data_1.chr + data_2.chr
@hiroeorz
hiroeorz / array-time-lazy.rb
Created May 6, 2014 05:34
ツナでもわかるmruby [5回目:配列と遅延評価] ref: http://qiita.com/hiroeorz@github/items/371a12316091c63a3aa8
start_time = Time.now
Array.new(1000000, 1).lazy.map{|e| e}.take(3).force
end_time = Time.now
process_time = end_time - start_time
puts "process time: #{process_time}"
@hiroeorz
hiroeorz / build_config.rb
Created May 7, 2014 23:16
ツナでもわかるmruby [6回目:コルーチン・非同期I/O] ref: http://qiita.com/hiroeorz@github/items/68acf89b768475af6e2c
MRuby::Build.new do |conf|
...
conf.gem :github => 'mattn/mruby-uv' #追加
...
end
@hiroeorz
hiroeorz / build_config.rb
Created May 19, 2014 08:53
ツナでもわかるmruby[7回目:mrbgemsの作り方メモ(勉強中)] ref: http://qiita.com/hiroeorz@github/items/d6fa2978d9f53a41c777
conf.gem '../mruby-mqtt'
FROM ubuntu
MAINTAINER Shin Hiroe <hogehoge@mail.com>
RUN echo "upgrade apt sources"
RUN apt-get update
RUN apt-get upgrade -y
EXPOSE 1883
RUN echo "install Mosquitto"
RUN apt-get install mosquitto -y
FROM ubuntu
MAINTAINER Shin Hiroe <hogehoge@mail.com>
RUN echo "upgrade apt sources"
RUN apt-get update
RUN apt-get upgrade -y
RUN echo "install wget"
RUN apt-get install wget -y
@hiroeorz
hiroeorz / file0.txt
Last active August 29, 2015 14:06
Riak 2.0.0 インストールから起動まで ref: http://qiita.com/hiroeorz@github/items/cc33bf0f26e80c7c500d
$ sudo apt-get install libpam0g-dev
$ sudo apt-get install libssl0.9.8
@hiroeorz
hiroeorz / file0.txt
Created September 5, 2014 09:21
Riak 2.0.0 へアップグレードする際の注意点 ref: http://qiita.com/hiroeorz@github/items/494cfac481add9594686
/buckets/<bucket>/keys/<key>
$ riak-admin bucket-type create maps '{"props":{"datatype":"map"}}'
maps created
$ riak-admin bucket-type create sets '{"props":{"datatype":"set"}}'
sets created
$ riak-admin bucket-type create counters '{"props":{"datatype":"counter"}}'
counters created