Skip to content

Instantly share code, notes, and snippets.

☕️
🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️

akira yamada arika

☕️
🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️
Block or report user

Report or block arika

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@arika
arika / .irbrc
Last active Feb 9, 2018
workaround to avoid suspending rb-readline by 'Ctrl-Y'. https://arika.org/2017/11/10/rb-readline-and-ctrl-y/
View .irbrc
# macOSでのrb-readline使用時の"\C-y"サスペンド問題の回避
if defined?(::RbReadline) && $".grep(/\/rbreadline.rb\z/)
stty = `stty -a`
stty_ccs = { 'dsusp' => '^Y', 'lnext' => '^V' }
stty_ccs.delete_if {|cc, key| /\b#{Regexp.quote("#{cc} = #{key}")};/ !~ stty }
unless stty_ccs.empty?
system('stty', *stty_ccs.keys.inject([]) {|opts, cc| opts << cc << 'undef' })
IRB.conf[:AT_EXIT] << proc do
@arika
arika / method_call_bm.rb
Created Nov 11, 2017
Ruby method call benchmark
View method_call_bm.rb
require 'benchmark/ips'
class Runner
def self.create(obj, method_name)
Class.new(self).class_eval do
eval <<-E
def run
@obj.#{method_name}
end
E
View gem_patch.rb
module GemDepPatch_
def to_specs
#super.select {|spec| spec.full_name != 'activesupport-5.1.2' }
super.sort_by {|spec| spec.activated? ? -1 : 1 }
end
end
Gem::Dependency.prepend(GemDepPatch_)
@arika
arika / gem_trace.out.txt
Last active Jul 11, 2017
output from "RUBYOPT=-r$(pwd)/gem_trace.rb middleman init --help" / ruby 2.4.1 / installed gems: middleman 4.2.1, activesupport 5.1.2, 4.2.9, 4.2.7.1
View gem_trace.out.txt
R rubygems
` rubygems
A middleman-cli-4.2.1
: A thor-0.19.4
: + thor-0.19.4
+ middleman-cli-4.2.1
R middleman-core/profiling
| A middleman-core-4.2.1
| : A bundler-1.15.1
| : + bundler-1.15.1
@arika
arika / gem_trace.rb
Last active Jul 11, 2017
debug tracing patch for gem error "`check_version_conflict': can't activate foo-2.0, already activated foo-1.0 (Gem::LoadError)"
View gem_trace.rb
def ___trace_push mark
Thread.current[:__prefix] ||= ''
Thread.current[:__prefix] << "#{mark} "
end
def ___trace_pop
Thread.current[:__prefix].slice!(-3, 3)
end
def ___trace_puts mark, *msgs
View client_auth_test.rb
# Generate files:
#
# ```
# ruby client_auth_test.rb dir
# ```
#
# Run Apache HTTP server:
#
# ```
# apachectl -d dir -f httpd.conf -X
View ruby_dictionary.rb
#!/usr/bin/env ruby
require 'rbconfig'
require 'shellwords'
require 'yaml'
require 'tmpdir'
def get_output(cmd)
IO.popen(cmd, 'r', &:read)
end
View kana01.rb
data=[
# [ id, input, expected ],
[ -1, "4", "4" ],
[ 0, "4*5+6&7|8", "44" ],
[ 1, "15*5", "75" ],
[ 2, "15+5", "20" ],
[ 3, "15&5", "5" ],
[ 4, "15|5", "15" ],
[ 5, "30*15*5", "2250" ],
[ 6, "30*15+5", "600" ],
@arika
arika / groonga.rb.diff
Created Dec 30, 2014
homebrew groonga.rb: enable mruby support and add tests.
View groonga.rb.diff
diff --git a/Library/Formula/groonga.rb b/Library/Formula/groonga.rb
index 386e7ca..94e0a41 100644
--- a/Library/Formula/groonga.rb
+++ b/Library/Formula/groonga.rb
@@ -39,7 +39,7 @@ class Groonga < Formula
--prefix=#{prefix}
--with-zlib
--disable-zeromq
- --with-mruby
+ --enable-mruby
@arika
arika / groonga.rb.diff
Last active Aug 29, 2015
brew install groonga with mruby-support
View groonga.rb.diff
with→enableの間違いを直すとonig-sourceの中身をbuildしてくれなくてコケるという流れ。
いきなりmake installでなく、いったんmakeすれば回避できるみたい。
diff --git a/Library/Formula/groonga.rb b/Library/Formula/groonga.rb
index 66a643d..441bddc 100644
--- a/Library/Formula/groonga.rb
+++ b/Library/Formula/groonga.rb
@@ -28,7 +28,7 @@ class Groonga < Formula
--prefix=#{prefix}
--with-zlib
You can’t perform that action at this time.