This file contains 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
package main | |
import ( | |
"io/ioutil" | |
"log" | |
"reflect" | |
yaml "gopkg.in/yaml.v2" | |
) |
This file contains 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
pp Dir.children(File.join(Gem.dir, 'gems')) | |
This file contains 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
# こんな感じでいけそうなんだけど、どうか | |
at_exit { | |
path = File.join(File.expand_path(__dir__)) | |
require_files = $LOADED_FEATURES.select{|f| f.start_with?(path)} | |
files = Dir.glob("./**/*.rb").map{|f| File.expand_path(f)}.select{|f| f.start_with?(path)} | |
diff = files - require_files | |
puts "*** not required files(#{ diff.size }) ***" | |
puts diff | |
} |
This file contains 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
irb(main):001:0> foo = {} | |
=> {} | |
irb(main):002:0> foo.default = "a" | |
=> "a" | |
irb(main):003:0> foo[:z] | |
=> "a" | |
irb(main):004:0> foo[:z].upcase! | |
=> "A" | |
irb(main):005:0> foo[:x] | |
=> "A" |
This file contains 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
# こんな感じでできそうだけど、内容があってるかは確認してない | |
Dir.glob(File.join(RbConfig.expand("$(libdir)"), 'ruby', "#{ RUBY_VERSION.split('.')[0, 2].join('.') }.0", "*.rb")).each do |path| | |
name = File.basename(path, ".rb") | |
next if %w(profile debug).include? name # こいつらをrequireするとプログラムが色々動いてしまうので除外 | |
require name | |
end |
This file contains 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 StandardError | |
def each_cause(&block) | |
e = self | |
while e | |
yield e | |
e = e.cause | |
end | |
end | |
end |
This file contains 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
for(let c of 'い𩸽あ😇'){ | |
console.log(c.charCodeAt(0).toString(16), c.charCodeAt(1).toString(16)) | |
} | |
3044 NaN | |
d867 de3d | |
3042 NaN | |
d83d de07 |
This file contains 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
# brew にあるのとXcodeとどっちをリンクしておくのが良いのだろうか(Xcodeの方がsymlinkなので汎用性ありそう) | |
% ls -l /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ | |
total 0 | |
drwxr-xr-x 5 root wheel 160 11 3 12:39 MacOSX.sdk | |
lrwxr-xr-x 1 root wheel 10 9 20 22:16 MacOSX10.13.sdk -> MacOSX.sdk | |
% bundle config build.nokogiri --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/libxml2 | |
This file contains 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
=begin | |
https://docs.ruby-lang.org/ja/latest/class/Exception.html#I_CAUSE | |
[START] -> foo error. | |
[FooError-0] : foo error. -> ["exception_sample.rb:19:in `rescue in run'", "exception_sample.rb:16:in `run'", "exception_sample.rb:37:in `<main>'"] | |
[BarError-1] : bar error. -> ["exception_sample.rb:9:in `rescue in run'", "exception_sample.rb:6:in `run'", "exception_sample.rb:17:in `run'", "exception_sample.rb:37:in `<main>'"] | |
[ZeroDivisionError-2] : divided by 0 -> ["exception_sample.rb:7:in `/'", "exception_sample.rb:7:in `run'", "exception_sample.rb:17:in `run'", "exception_sample.rb:37:in `<main>'"] | |
[END] | |
=end |
This file contains 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
irb(main):001:0> begin | |
irb(main):002:1* raise ArgumentError, '何かエラー' | |
irb(main):003:1> rescue => e | |
irb(main):004:1> puts "e.class = #{ e.class }" | |
irb(main):005:1> puts "e.message = #{ e.message }" | |
irb(main):006:1> end | |
e.class = ArgumentError | |
e.message = 何かエラー | |
=> nil |