Today I Learned

TIL, 2017-07-02

  • Bash: set -e to terminate the script when something goes wrong.
  • Bash: set -x to print each command that is going to be executed with a little plus.
  • Bash: set -u: Treats unset variables as an error and exit immediately.
  • Bash: set -v: Prints shell input lines as they are read.


pgrep -x ruby > /dev/null => pgrep to see if a process is running
                          => /dev/null: this redirects the command standard output to the null device, which is a special device which discards the information written to it
if [ $? -eq 0 ]; then     => this is how loops are in bash
  killall -9 ruby         => the $? variable is "the exit code of the last command.
  • Only rescue StandardError at least.
  • Fixing “Unresolved specs during Gem::Specification.reset:” gem cleanup minitest or whatever it was.
  • Make sure integer strings and work: Integer("25").
  • Avoid rescue in the modifier form (5 / 0 rescue nil), just use the block form.
  • pry-nav is for JRuby, pry-byebug is for MRI. They might conflict especially in 2.4.0.
  • default_scope: Think about this again.
  • rspec spec bases itself on the db/schema, not the migration.

This project is maintained by daryllxd