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
SELECT table_name, table_rows AS tbl_rows, avg_row_length AS rlen,
floor((data_length+index_length)/1024/1024) AS allMB,
floor((data_length)/1024/1024) AS dMB,
floor((index_length)/1024/1024) AS iMB
FROM information_schema.tables
WHERE table_schema=database()
ORDER BY (data_length+index_length) desc;
@ravelll
ravelll / .php_cs
Created December 31, 2015 16:47
fix setting config file for StyleCI/PHP-CS-Fixer
<?php
$finder = Symfony\CS\Finder\DefaultFinder::create()
->in(__DIR__);
return Symfony\CS\Config\Config::create()
->setRules(array(
'array_element_white_space_after_comma' => true,
'array_element_no_space_before_comma' => true,
'concat_without_spaces' => true,
@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