This week in #dev (Aug 18, 2023)

Welcome to another edition of This Week in #dev, a series of posts where we bring some of our most interesting Slack conversations to the public.

The Autostash Option in Git Pull

Mike Burns explained the --autostash and --no-autostash options in git-pull(1). These options allow you to automatically create a temporary stash entry before the operation begins and apply it after the operation ends. However, caution should be exercised as conflicts may arise during the final stash application after a successful merge.

Caching HTTP Responses Forever

Steve Polito learned about Rails’ http_cache_forever helper method for caching HTTP responses indefinitely. He gives an example of using it for a static page that never changes:

class HomeController < ApplicationController
  def index
    http_cache_forever(public: true) do
      render
    end
  end
end

Is Your Terminal Acting Weird?

Sara Jackson suggested using the stty sane command to quickly reset your terminal settings if it is not registering enters or tabs correctly. Accidental key presses or other factors may cause this issue.

Boost Your Efficiency with Bash Macros

Summer ☀️ shares a tip about adding text-expansion shortcuts (“macros”) in the Bash prompt. For example, create a ~/.inputrc file with the contents "\C-b": "bundle exec ". After quitting the current shell session and starting a new one, hitting Ctrl+B will type bundle exec!

Note that the example above will add the shortcut to many other prompts/REPLs too, such as IRB, Python, psql etc. For this reason, they recommended surrounding the macros with a conditional:

$if Bash
    "\C-b": "bundle exec "
$endif

$if Ruby
    "\C-b": "beep boop"
$endif

For more info, check out the Readline user guide.

Introducing ASCIIflow: A Visual Tool for Clear Communication

Aji introduces ASCIIflow as one of their favorite tools. ASCIIflow is a chart-making tool that can be included in commit messages. Here’s an example:

     ┌────────────────────────┐
     ▼                        │
┌──────────┐   ┌───────────┐  │  ┌────────────┐
│  Intake  │   │  Payment  │  │  │  Bill      │
├──────────┤   ├───────────┤  │  ├────────────┤
│  id      │   │  payable  │  └──┤  billable  │
└──────────┘   └─────┬─────┘     │  type      │
      ▲              │           └────────────┘
      │              │                 ▲
      └──────────────┴─────────────────┘
               through :payable

Thanks

This edition was brought to you by Aji, Mike Burns, Sara Jackson, Steve Polito, and Summer ☀️. Thanks to all contributors! 🎉