Skip to content

Instantly share code, notes, and snippets.

View arika's full-sized avatar
🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️

akira yamada arika

🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️
View GitHub Profile
@arika
arika / .spring.rb
Last active August 3, 2018 04:18
auto stop spring server
module DotSpringRb
MONITOR_INTERVAL = 10*60
SERVER_KEEP_PERIOD = 30*60
module_function
def env
@env ||= Spring::Env.new
end
@arika
arika / .vimrc
Last active April 27, 2018 01:19
https://github.com/janko-m/vim-test のtest-unit対応 .vim/autoload/test/ruby/testunit.vim (rails.vimとminitest.vimからのコピペ)
let test#runners = {'Ruby': ['TestUnit']}
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'time'
require 'optparse'
require 'ostruct'
require 'fileutils'
class Index
reqid_regexp = /\h{8}-\h{4}-\h{4}-\h{4}-\h{12}/
require 'shellwords'
class MiniMagickCommandExecutionTrace
OUTPUT = $stderr
TERM = {
green: "\e[32m",
red: "\e[31m",
yellow: "\e[33m",
reset: "\e[m",
}.freeze
@arika
arika / to_rouge.rb
Created November 14, 2017 13:50
RI Rouge
# Usage:
#
# RUBYOPT='-r ./to_rouge' RI_ROUGE=monokai.sublime \
# ri --format=rouge Class.methods
require 'rdoc'
require 'rouge'
module RDoc
class Markup
@arika
arika / .irbrc
Last active February 9, 2018 07:23
workaround to avoid suspending rb-readline by 'Ctrl-Y'. https://arika.org/2017/11/10/rb-readline-and-ctrl-y/
# 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 November 11, 2017 05:58
Ruby method call benchmark
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
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 July 11, 2017 10:21
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
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 July 11, 2017 10:18
debug tracing patch for gem error "`check_version_conflict': can't activate foo-2.0, already activated foo-1.0 (Gem::LoadError)"
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