My favorite time I had to do this was for a real-life situation. I wanted a script that was both a bash script (for speed) and a ruby script (if you installed it the default way).
I came up with: https://github.com/sorbet/sorbet/blob/master/gems/sorbet/bin...