第213回 Okinawa.rb Meetup @ 那覇で披露しました。 https://okinawarb.doorkeeper.jp/events/90112
今のtrunk(Ruby 2.7)でしか動きません。
RubyKaigi 2019のCookpad Daily Ruby Puzzlesがとてもおもしろかったので、お返しパズルです。 https://techlife.cookpad.com/entry/2019/04/25/122520
klass_or_module = Object.constants.map(&Object.method(:const_get)).select {|klass| klass.is_a?(Class) || klass.is_a?(Module) } | |
tarinai = {} | |
klass_or_module.each do |klass| | |
tarinai[klass.name.to_s] = klass.public_instance_methods(false) - `exe/rbs methods #{klass.name} | cut -f1 -d" " | sort`.split.map(&:to_sym) | |
end | |
tarinai_singleton = {} | |
klass_or_module.each do |klass| | |
tarinai_singleton[klass.name.to_s] = klass.singleton_methods - `exe/rbs methods --singleton #{klass.name} | cut -f1 -d" " | sort`.split.map(&:to_sym) | |
end |
% time RUBOCOP_SPEC_URL=SECRET go run run-test.go | tee result.txt | |
% cat result.txt | ruby -npe '~/summary_line":"([^"]*)"/;$_=$_.split(?:,2)[0]+":"+($1||"")+"\n"' |
$<.map{|l,n=1|l[l.to_i.to_s n+=1]||redo;p n} | |
$<.map{|l,n=1|l[l.to_i.to_s n+=1]||redo;n} | |
#!ruby -n | |
$_[$_.to_i.to_s n=n.to_i+1]||redo;p n | |
__END__ | |
#!ruby -n | |
$_[$_.to_i.to_s n=n.to_i+1]||redo;p n | |
$<.map{|l=n=1|$_[$_.to_i.to_s n+=1]||redo;p n} | |
__END__ | |
$<.map{|l,n=1|l[l.to_i.to_s n+=1]||redo;p n} |
// ==UserScript== | |
// @name Anarchy Golf reveal statics | |
// @namespace https://hanach.in/ | |
// @version 0.1 | |
// @description Automatically check code-statics | |
// @author hanachin | |
// @match http://golf.shinh.org/p.rb?* | |
// @grant none | |
// @run-at document-idle | |
// ==/UserScript== |
using Module.new { | |
refine(Integer) do | |
def >(f) | |
f.call __method__ | |
end | |
def <(f) | |
f.call __method__ | |
end |
@stage: 0 | |
let-rec seq-int s e = | |
let-rec r n = | |
&( | |
if ~n > ~e then | |
[] | |
else | |
~n :: ~(r &(~n + 1)) | |
) |
#!/home/sei/.rbenv/versions/2.6.3/bin/ruby --disable-gems | |
require "rbconfig" | |
$LOAD_PATH << "/home/sei/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib" << "/home/sei/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/msgpack-1.2.10/lib" | |
require 'bootsnap' | |
gem_name = 'rubocop' | |
exe_name = 'rubocop' | |
cache_dir = File.join(ENV['HOME'], '.cache', 'bootsnap', gem_name, exe_name, 'disable-gems') | |
Bootsnap.setup(cache_dir: cache_dir, load_path_cache: false, autoload_paths_cache: false) | |
require "rubygems.rb" | |
load "/home/sei/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rubocop-0.70.0/exe/rubocop" |
module Hi | |
instance_methods_snapshot = [] | |
TracePoint.trace(:class) do |tp| | |
next unless tp.self == self | |
# Hi.singleton_class.prepend Module.new { define_method(:method_added) { "ここで最小限のスナップショットを取ることも可能" } } | |
instance_methods_snapshot = instance_methods.map(&method(:instance_method)) | |
end | |
TracePoint.trace(:end) do |tp| |
diff --git a/exe/rubocop b/exe/rubocop | |
index abf88369e..9491ded7f 100755 | |
--- a/exe/rubocop | |
+++ b/exe/rubocop | |
@@ -3,6 +3,9 @@ | |
$LOAD_PATH.unshift("#{__dir__}/../lib") | |
+require 'bootsnap' | |
+Bootsnap.setup(cache_dir: '/tmp/rubocop/', load_path_cache: false, autoload_paths_cache: false) |
第213回 Okinawa.rb Meetup @ 那覇で披露しました。 https://okinawarb.doorkeeper.jp/events/90112
今のtrunk(Ruby 2.7)でしか動きません。
RubyKaigi 2019のCookpad Daily Ruby Puzzlesがとてもおもしろかったので、お返しパズルです。 https://techlife.cookpad.com/entry/2019/04/25/122520