Skip to content

Instantly share code, notes, and snippets.

@ravelll
ravelll / ruby_static_type_check.md
Created July 21, 2020 14:33
Ruby の静的解析に関する情報

p.vi

コンピューティングはポップカルチャーです。(...)ポップカルチャーは、歴史を重んじ ません。ポップカルチャーは、アイデンティティと当事者意識に他なりません。それは他者との協力や過去、未来とは関係なく、今を生きることです。

めっちゃいい


p.xii

  • なぜこの本を書いた?
# Classes are from https://docs.ruby-lang.org/ja/2.6.0/library/_builtin.html
classes = [
BasicObject,
Object,
Array,
Binding,
ConditionVariable,
Data,
Dir,
Encoding,
### Inspect where a method is called
def foo(x, y)
p caller # Kernel#caller
# ...
end
### Inspect where a method is defined
# Where is obj.foo defined?
p obj.method(:foo).source_location # Method#source_location
def answer?(str)
filtered = str.split('').keep_if{|s| s.match(/[a-zA-Z0-9-]/)}
if filtered && filtered.count == filtered.uniq.count
return true
end
false
end
@ravelll
ravelll / cVimrc
Last active October 27, 2016 02:15
iunmap <C-p>
iunmap <C-k>
map <C-f> scrollFullPageDown
map <C-b> scrollFullPageUp
let hintcharacters="asdfghjklerui"
let typelinkhintsdelay="50"
10.upto(63) do |i|
10.upto(63) do |k|
IO.write(
i.to_s + k.to_s + ".jpg",
open('./hoge.jpg').read.force_encoding('ascii-8bit').gsub(i.to_s, k.to_s)
)
end
end
#!/usr/bin/env ruby
require 'benchmark'
class Array
def quick_sort
return self if self.length <= 1
pivot = pop
left, right = partition { |e| e < pivot }
push pivot
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.006 000.006: --- VIM STARTING ---
000.072 000.066: Allocated generic buffers
001.034 000.962: locale set
001.039 000.005: clipboard setup