Just some tips I found useful

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

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).

Last updated on Wednesday, May 6, 2020
Published on Wednesday, May 6, 2020