Skip to content

Instantly share code, notes, and snippets.

@hkdnet
hkdnet / kick-and-wait.sh
Created July 5, 2021 00:58
Kick and wait CircleCI WF
#!/bin/bash -eux
set -o pipefail
org=$1
repo=$2
branch=$3
get_status() {
curl -fs --retry 3 -X GET -u ${CIRCLE_TOKEN}: \
--url "https://circleci.com/api/v2/pipeline/$1/workflow"
diff --git a/struct.c b/struct.c
index ceb025ff83..6fc489e3a2 100644
--- a/struct.c
+++ b/struct.c
@@ -1401,6 +1401,8 @@ InitVM_Struct(void)
rb_undef_alloc_func(rb_cStruct);
rb_define_singleton_method(rb_cStruct, "new", rb_struct_s_def, -1);
+ rb_define_singleton_method(rb_cStruct, "keyword_init?", rb_struct_s_keyword_init, 0);
+
@hkdnet
hkdnet / config.ru
Last active October 28, 2019 06:27
require 'rack'
require 'rack/lobster'
class Streaming
class Stream
def each
%w[a b c].each do |e|
puts "Stream#each with #{e}"
sleep 1
yield e
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 3380720f47..744fadde92 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -1959,6 +1959,8 @@ Init_readline(void)
mReadline = rb_define_module("Readline");
rb_define_module_function(mReadline, "readline",
readline_readline, -1);
+ rb_define_module_function(mReadline, "readmultiline",
+ readline_readline, -1);
require 'logger'
logger1 = Logger.new('/tmp/logger/1.log')
logger1.level = Logger::Severity::DEBUG
logger2 = logger1.dup
logger2.level = Logger::Severity::INFO
logger1.info('1 info')
logger2.info('2 info')
logger1.debug('1 debug')
@hkdnet
hkdnet / patch.rb
Created August 15, 2018 05:50
rack middleware ごとの経過時間をはかるやつ
# ref: http://blog.mirakui.com/entry/2012/04/03/slow-middleware
module RackMiddlewareBenchmarker
module Benchmarker
def call(env)
result = nil
ms = Benchmark.ms { result = super }
puts "MIDDLEWARE END #{self.class.to_s} (#{ms.to_i}ms)"
result
end
end
@hkdnet
hkdnet / deconst.patch
Last active August 10, 2018 10:03
union の deconst 外すやつ
diff --git a/iseq.c b/iseq.c
index 997dd7f1f7..be9efb9aad 100644
--- a/iseq.c
+++ b/iseq.c
@@ -989,11 +989,8 @@ static const rb_data_type_t iseqw_data_type = {
static VALUE
iseqw_new(const rb_iseq_t *iseq)
{
- union { const rb_iseq_t *in; void *out; } deconst;
VALUE obj;
3s 3sec
4s 4sec
@hkdnet
hkdnet / bash
Created September 18, 2017 08:53
vernacular
$ bundle exec ruby exec.rb
== disasm: #<ISeq:<compiled>@src.rb>====================================
0000 trace 1 ( 1)
0002 putself
0003 putobject 10
0005 putobject 2
0007 opt_plus <callinfo!mid:+, argc:1, ARGS_SIMPLE>, <callcache>
0010 opt_send_without_block <callinfo!mid:puts, argc:1, FCALL|ARGS_SIMPLE>, <callcache>
0013 pop
0014 trace 1 ( 2)