Skip to content

Instantly share code, notes, and snippets.

View mlocati's full-sized avatar

Michele Locati mlocati

View GitHub Profile
#!/bin/sh
# A post-receive git hook to publish a specific branch to a working tree,
# optionally updating Composer dependencies and/or ConcreteCMS.
#
# Invoke this file from hooks/post-receive.
# For example:
#
# #!/bin/sh
# /path/to/this-file /path/to/repo.git /path/to/worktree --branch main --composer --concrete --concrete-languages 'de_DE fr_FR it_IT'
@mlocati
mlocati / git-post-receive-hook
Last active January 23, 2026 16:42
A git post-receive hook to publish/deploy websites
#!/bin/sh
# A post-receive git hook to publish a specific branch to a working tree,
# optionally updating Composer dependencies and/or ConcreteCMS.
#
# Invoke this file from hooks/post-receive.
# For example:
#
# #!/bin/sh
# /path/to/this-file /path/to/repo.git /path/to/worktree --branch main --composer --concrete --concrete-languages 'de_DE fr_FR it_IT'
@mlocati
mlocati / update-concrete
Last active January 23, 2026 16:38
Script to safely and fully update ConcreteCMS
#!/bin/sh
# First argument (required): path to the directory that contains the ConcreteCMS installation
# Subsequent arguments (optional): language codes to install/update translations for (e.g. 'fr_FR', 'de_DE', etc.)
#
# Copyright Michele Locati <michele@locati.it> - 2026
# License: MIT - https://opensource.org/license/mit
# Source: https://gist.github.com/mlocati/2195c70caeca3df1240e35d5db871587
set -o nounset
@mlocati
mlocati / get-windows-ip.sh
Created September 9, 2025 07:04
Determine the Windows IP from inside WSL
ip route show | grep ^default | cut -d' ' -f3
@mlocati
mlocati / timezone-constants-creator.php
Last active October 23, 2024 17:13
Convert time zone identifiers to/from PHP from/to Windows
<?php
/*
* License: MIT
* Author: Michele Locati <michele@locati.it>
*/
declare(strict_types=1);
set_error_handler(
@mlocati
mlocati / attach-release-asset.yml
Last active May 13, 2023 11:22
Attach concrete5/ConcreteCMS package archive to releases
name: Attach release asset
on:
release:
types:
- created
jobs:
attach_release_asset:
name: Attach release asset
@mlocati
mlocati / create-release-asset.sh
Created August 6, 2021 09:57
Attach concrete5/ConcreteCMS
#!/bin/sh
set -o errexit
set -o nounset
printf -- '- cleanup... '
rm -rf ./tmp
mkdir ./tmp
echo 'done.'
@mlocati
mlocati / list-pecl-versions.php
Created December 8, 2020 11:44
List all currently defined versions of PECL packages
<?php
set_error_handler(
static function ($errno, $errstr, $errfile, $errline)
{
$message = trim((string) $errstr);
if ($message === '') {
$message = "Unknown error (code: {$errno})";
}
if ($errfile) {
@mlocati
mlocati / fix-ckeditor-eol.php
Last active November 10, 2020 17:23
Fix CKEditor 4 line endings
#!/usr/bin/env php
<?php
const FIX_EOL = true;
const FIX_BOM = true;
set_error_handler(
static function ($errno, $errmsg, $errfile, $errline)
{
throw new RuntimeException("Error {$errno}: {$errmsg}\nFile: {$errfile}\nLine: {$errline}");
@mlocati
mlocati / concrete5-migrations-checker.php
Created July 3, 2020 12:04
Check concrete5 migration IDs
<?php
declare(strict_types=1);
set_error_handler(
static function ($code, $message, $file, $line): void
{
throw new RuntimeException("{$message}\nFile: {$file}\nLine: {$line}");
},
-1
);