This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
def define_mixable_method(name:, calls:, main:) | |
define_method(name) do |&block| | |
method_candidates = calls.map {|name| method(name) } | |
block.call(main, method_candidates).each do |m| | |
m.call | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module EachWithEffect | |
DEFAULT = Object.new.freeze | |
def each_with_effect(effect_handlers = {}, &block) | |
effect = catch(:effect) do | |
block.call(self.peek) | |
end | |
if effect | |
handler = effect_handlers.find{ |k, v| k === effect }&.last || effect_handlers.fetch(DEFAULT) | |
alternative = handler.call(effect) if handler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WithEffect | |
def initialize | |
@list = ["Foo", "Bar", 42, "Baz"] | |
end | |
def process_item(item) | |
throw(:item_not_string, 42) unless item.is_a?(String) | |
puts item | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GIT heart FZF | |
# ------------- | |
is_in_git_repo() { | |
git rev-parse HEAD > /dev/null 2>&1 | |
} | |
fzf-down() { | |
fzf --height 50% --min-height 20 --border --bind ctrl-/:toggle-preview "$@" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ライブラリコード | |
module MyDSL | |
class ClassMacro < Module | |
class StoredItem | |
attr_reader :name | |
attr_accessor :context | |
def initialize(name, block_args: [], &block) | |
@name = name | |
@block_args = block_args | |
@block = block |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
huge_array = (1..10000000).to_a | |
Benchmark.bmbm do |x| | |
puts "Adding all numbers" | |
x.report(:sum) { huge_array.sum } | |
x.report(:plus_equal) { sum = 0; huge_array.each {|i| sum += i }; sum} | |
x.report(:inject) { huge_array.inject(:+) } | |
x.report(:inject_block) { huge_array.inject(0) {|memo, i| memo + i} } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
source "https://rubygems.org" | |
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } | |
gem "rails" | |
gem "sqlite3" | |
gem "jbuilder" | |
gem "active_model_serializers" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HogeSerializer < ActiveModel::Serializer | |
attributes :id, :hogehoge | |
has_many :fugas do |fuga| | |
fuga.attributes :id, :fugafuga | |
fuga.has_many :bars do |bar| | |
bar.attributes :id, :barbar | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Keynote: Vim Renaissance | |
By Prabir Shrestha | |
"I'm thankful to people in vim-jp" | |
"With LSP, you don't have to configure for every language!" | |
"If you're not using LSP, go use it!" | |
It works with every language, every OS, in Vim8 or Neovim...Great! | |
He talks about vim so passionately, that's awesome. | |
He says "Go use it!" so many times, I'd like to use LSP more! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/proc.c b/proc.c | |
index 19ce7a1d19..3eb8c9445d 100644 | |
--- a/proc.c | |
+++ b/proc.c | |
@@ -1196,6 +1196,24 @@ iseq_location(const rb_iseq_t *iseq) | |
return rb_ary_new4(2, loc); | |
} | |
+static VALUE | |
+iseq_code_location(const rb_iseq_t *iseq) |