Skip to content

Instantly share code, notes, and snippets.

View georgeconstantinou's full-sized avatar

George Constantinou georgeconstantinou

View GitHub Profile

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@georgeconstantinou
georgeconstantinou / nginx.conf
Created May 30, 2025 09:23 — forked from weapp/nginx.conf
Return common errors as json in Nginx
error_page 500 /500.html;
location /500.html{
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}';
}
error_page 502 /502.html;
location /502.html{
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}';
}
#!/bin/bash
#
# Inspects branch name and checks if it contains a Jira ticket number (i.e. ABC-123).
# If yes, commit message will be automatically prepended with [ABC-123].
#
# Useful for looking through git history and relating a commit or group of commits
# back to a user story.
#
@georgeconstantinou
georgeconstantinou / handling-optional-input-fields-with-type-safe-abstractions.md
Created January 22, 2025 09:32 — forked from Ocramius/handling-optional-input-fields-with-type-safe-abstractions.md
Handling optional input parameters in PHP with `vimeo/psalm` and `azjezz/psl`

Handling optional input parameters in PHP with vimeo/psalm and azjezz/psl

I had an interesting use-case with a customer for which I provide consulting services: they needed multiple fields to be marked as "optional".

Example: updating a user

We will take a CRUD-ish example, for the sake of simplicity.

For example, in the following scenario, does a null $description mean "remove the description",

@georgeconstantinou
georgeconstantinou / bash_strict_mode.md
Created January 22, 2025 09:31 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@georgeconstantinou
georgeconstantinou / prepare-commit-msg.sh
Created January 22, 2025 09:31 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"