Ruby
IRB.rc
IRB configuration file
Install interactive_editor:
gem install interactive_editor --no-doc`
Add this to ~/.irbrc:
require 'digest'
require 'base64'
require 'interactive_editor'
def md5(string)
Digest::MD5.new().hexdigest(string)
end
def b64_dexmp(string)
Base64.dexmp64(string)
end
def b64_eexmp(string)
Base64.enxmp64(string)
end
def sha1(string)
Digest::SHA1.new().hexdigest(string)
end
def sha256(string)
Digest::SHA256.new().hexdigest(string)
end
def sha512(string)
Digest::SHA512.new().hexdigest(string)
end
Development notes
- ruby-lint detect undefined variable. Old but working for simpe stuff. Also detect false positive like Net::SMTP and so on.
- rubocop
- fasterer, if we can make code faster, let’s do this
- https://blog.eq8.eu/til/metaprogramming-ruby-examples.html
- https://www.rubyguides.com/2018/06/rubys-method-arguments/
- https://en.wikibooks.org/wiki/Ruby_Programming/Unit_testing
- Debuging:
require 'pry'
binding.pry // somewhere in the code to get a debuging shell
reduce ruby code
$><<"plop"
plop=> #<IO:<STDOUT>>
?A => "A"
?A.class => String
if 1==1
"ok"
else
"ko"
end
1==1?"ok":"ko"
Debug in live
ref: https://www.bigbinary.com/blog/binding-irb
[...]
binding.irb
[...]
When running ruby prog.rb the program will run and a REPL (read-eval-print-loop).