Skip to content

Instantly share code, notes, and snippets.

View denniseilander's full-sized avatar
🚀

Dennis denniseilander

🚀
View GitHub Profile
@denniseilander
denniseilander / commit-msg
Last active October 19, 2023 14:24
Git commit hook to always append the ticket number of the current branch when making a commit.
#!/bin/bash
# Get the current branch name
branch=$(git symbolic-ref --short HEAD)
# Extract the ticket number from the branch name e.g. feature/AB-123
# This regex assumes that the ticket number is always preceded by a '/'
ticket_number=$(echo $branch | sed -n 's/.*\/\([A-Z]*-[0-9]*\)/\1/p')
# If a ticket number was found, append it to the commit message
@denniseilander
denniseilander / AsJson.php
Last active June 11, 2021 12:39
Force http requests and responses as json output. When making requests to an endpoint, there is no need to add the Content-Type and Accept application/json headers anymore.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
class AsJson extends Middleware
{