Hey! Welcome to another edition of This Week in #dev, a series of posts where we bring some of the most interesting Slack conversations to the public. Today we’ll talk about randomness, shell commands, flaky tests, and TypeScript. Stick around!
# Calling system will return true, false or nil. system("pgrep ruby") # 76532 # => true # Using a backtick returns the standard output. `pgrep ruby` # => "76532\n"
Thiago Silva points out that you can use
$? to check the exit status of the
`echo oops && exit 99` #=> "oops\n" $?.exitstatus #=> 99
If you require the
English library, you can use
$CHILD_STATUS instead of
$?. It adds a few other aliases, if you’re interested.
`echo oops && exit 99` #=> "oops\n" $CHILD_STATUS.success? #=> false
Matheus Richard learned about https://www.random.org, a “true number generator”. The randomness comes from atmospheric noise, which for many purposes, it’s claimed to be better than the pseudo-random number algorithms typically used in computer programs.
Richard Newman shares an article about how to deal with flaky system tests in
sleeping is not the answer.
If you’re coming from a dynamically-typed language to TypeScript, Stephen Hanson has some tips for you:
It’s essential that you use an editor that has TypeScript tooling (i.e. that runs a TypeScript language server). You should be able to see TypeScript errors inline, hover over variables to see what type they are, and get auto-completion as you access properties on objects. If your editor does not have this tooling, then TypeScript is serving little value for you, and it will be a frustrating experience identifying errors only when you manually compile the code. VS Code has all this built-in by default.