Skip to content

Instantly share code, notes, and snippets.

View extend_ebs.sh
instance_ids=""
device_name=""
for vol in $(aws ec2 describe-instances --region ap-northeast-1 --instance-ids ${instance_ids} | jq '.Reservations[].Instances[] | .BlockDeviceMappings[] | select(.DeviceName == "'${device_name}'") | .Ebs.VolumeId' -r); do
current=$(aws ec2 describe-volumes --volume-ids ${vol} | jq '.Volumes[] | .Size')
target=$(expr $current + 50)
echo "${vol}: ${current} -> ${target}"
echo "aws ec2 modify-volume --volume-id ${vol} --size ${target} --dry-run"
#aws ec2 modify-volume --volume-id ${vol} --size ${target} --dry-run
done
@joker1007
joker1007 / 01-for.rb
Last active Mar 25, 2021
ruby_for_insn
View 01-for.rb
for i in [1, 2, 3]
p i
j = i
end
p j
[1, 2, 3].each do |k|
l = k
end
@joker1007
joker1007 / benchmark.md
Last active Jan 11, 2021
Ruby-3.0.0 benchmark with optcarrot on Ryzen9 5900X
View benchmark.md

Environment

Linux 5.10.6-gentoo #1 SMP PREEMPT Mon Jan 11 02:51:36 JST 2021 x86_64 AMD Ryzen 9 5900X 12-Core Processor AuthenticAMD GNU/Linux
% cat /proc/cpuinfo
processor	: 0
vendor_id	: AuthenticAMD
@joker1007
joker1007 / segv_with_debug_inspector_and_tracepoint.rb
Last active Jul 23, 2019
segv with debug_inspector and tracepoint
View segv_with_debug_inspector_and_tracepoint.rb
require "debug_inspector"
class Foo
def meth1(&block)
RubyVM::DebugInspector.open do |dc|
iseq = dc.frame_iseq(2)
trace = TracePoint.new(:b_return) do |tp|
pp tp
tp.disable
end
@joker1007
joker1007 / gist:9819ea8b1c891943fbc1d69acdfe464c
Last active Mar 1, 2019
Behavior of Struct with keyword_init
View gist:9819ea8b1c891943fbc1d69acdfe464c
どうやらたまたま
[6] pry(main)> S = Struct.new(:foo, :bar, keyword_init: true)
=> S(keyword_init: true)
[7] pry(main)> S.new(1, 2)
ArgumentError: wrong number of arguments (given 2, expected 0)
from (pry):10:in `initialize'
[8] pry(main)> S.new(foo: 1, bar: 2)
=> #<struct S foo=1, bar=2>
[9] pry(main)> S.new(foo: 1, **{bar: 2})
View proc_test.rb
class Symbol
alias :& :to_proc
end
pp ((1..)%2).each.lazy.map(&(:succ.& >> :succ.& >> :to_s.&)).take(10).force
View alter_defer.rb
class Object
def defer(method, *args)
@current_fibers ||= []
@tracepoint ||= TracePoint.trace(:return) do |tp|
@current_fibers.reverse_each do |fib|
fib.resume
end
end
@current_fibers << Fiber.new do
@joker1007
joker1007 / unbound_method.rb
Created Jan 23, 2018
unbound method equality
View unbound_method.rb
class C1
def meth
end
end
class C2 < C1
def meth
end
end
@joker1007
joker1007 / log.md
Created Oct 4, 2017
fluentd in_foward error?
View log.md
Oct 04 22:05:37 ip-172-31-11-88 fluentd-aggregator: 2017-10-04 13:05:31 +0000 [error]: #0 unexpected error on reading data host="ip-172-31-14-22.ap-northeast-1.compute.internal" port=34018 error_class=NoMethodError error="undefined method `[]=' for nil:NilClass"
Oct 04 22:05:37 ip-172-31-11-88 fluentd-aggregator:   2017-10-04 13:05:31 +0000 [error]: #0 /fluentd/etc/vendor/bundle/ruby/2.3.0/gems/fluentd-0.14.20/lib/fluent/plugin/in_forward.rb:367:in `block in add_source_info'
Oct 04 22:05:37 ip-172-31-11-88 fluentd-aggregator:   2017-10-04 13:05:31 +0000 [error]: #0 /fluentd/etc/vendor/bundle/ruby/2.3.0/gems/fluentd-0.14.20/lib/fluent/event.rb:264:in `block in each'
Oct 04 22:05:37 ip-172-31-11-88 fluentd-aggregator:   2017-10-04 13:05:31 +0000 [error]: #0 /fluentd/etc/vendor/bundle/ruby/2.3.0/gems/fluentd-0.14.20/lib/fluent/event.rb:261:in `feed_each'
Oct 04 22:05:37 ip-172-31-11-88 fluentd-aggregator:   2017-10-04 13:05:31 +0000 [error]: #0 /fluentd/etc/vendor/bundle/ruby/2.3.0/gems/fluentd-0.14.20/lib/f
@joker1007
joker1007 / gist:60b7f8e8dc1131656800f34342985fb3
Last active Sep 27, 2017
[Resolved] fluentd out_relabe is buffered??
View gist:60b7f8e8dc1131656800f34342985fb3
<match dummy.tag>
  @type copy

  <store>
    @type relabel
    @label @bigquery-out
  </store>

  <store>