In a headless setup, I wanted to protect the user registration endpoint from being accessed by unauthenticated users. I achieved it using the Simple Oauth module.
I'm setting up a controller on Drupal 8 which should redirct to the home page if certain query parameters aren't set. Writing a test to make sure that the redirect happens correctly took longer than expected. After trying a number of different approaches, I finally figured it out.
I make it a habit to ignore all file permission changes in Git, but sometimes I need to make a script executable. This is how I change the permissions on a file in such a way that they're stored in the repo.