Skip to content

Instantly share code, notes, and snippets.

Avatar

Michele Locati mlocati

View GitHub Profile
@mlocati
mlocati / attach-release-asset.yml
Last active Aug 6, 2021
Attach concrete5/ConcreteCMS package archive to releases
View attach-release-asset.yml
name: Attach release asset
on:
release:
types:
- created
jobs:
attach_release_asset:
name: Attach release asset
@mlocati
mlocati / create-release-asset.sh
Created Aug 6, 2021
Attach concrete5/ConcreteCMS
View create-release-asset.sh
#!/bin/sh
set -o errexit
set -o nounset
printf -- '- cleanup... '
rm -rf ./tmp
mkdir ./tmp
echo 'done.'
@mlocati
mlocati / list-pecl-versions.php
Created Dec 8, 2020
List all currently defined versions of PECL packages
View list-pecl-versions.php
<?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 Nov 10, 2020
Fix CKEditor 4 line endings
View fix-ckeditor-eol.php
#!/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}");
View concrete5-migrations-checker.php
<?php
declare(strict_types=1);
set_error_handler(
static function ($code, $message, $file, $line): void
{
throw new RuntimeException("{$message}\nFile: {$file}\nLine: {$line}");
},
-1
);
@mlocati
mlocati / Enable-HyperV.ps1
Last active Jul 30, 2020
Enable or disable Hyper-V (to switch between VirtualBox and Docker for Windows, for example)
View Enable-HyperV.ps1
<#
To enable Hyper-V:
Enable-HyperV.ps1 $True
To disable Hyper-V:
Enable-HyperV.ps1 $False
Author: Michele Locati <michele@locati.it>
License: MIT
Source: https://gist.github.com/mlocati/bb146577785511b44412e2fb57f969a6
#>
@mlocati
mlocati / app.php
Last active Sep 29, 2019
Install concrete5 on Android (Termux)
View app.php
<?php
// Save this file as /application/bootstrap/app.php
if (!function_exists('fnmatch')) {
// Shim for fnmatch
// Code from https://www.php.net/manual/en/function.fnmatch.php#100207
define('FNM_PATHNAME', 1);
define('FNM_NOESCAPE', 2);
define('FNM_PERIOD', 4);
define('FNM_CASEFOLD', 16);
@mlocati
mlocati / check-go-pear.phar.sh
Created Jan 23, 2019
Check if a go-pear.phar file is an official one
View check-go-pear.phar.sh
#!/bin/sh
# This script checks if a go-pear.phar is the same as one of the
# ones released on https://github.com/pear/pearweb_phars
#
# MIT License
# Made by Michele Locati <michele@locati.it> on 2019-01-23
set -o errexit
set -o nounset
@mlocati
mlocati / output.html
Last active Mar 15, 2017
Punic units
View output.html
<!DOCTYPE html>
<html>
<head>
<title>Punic Units sample</title>
<meta name="charset" value="utf-8" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
</body>
<table class="table table-striped table-bordered">
@mlocati
mlocati / exceptions-tree.php
Created Mar 9, 2017
Throwable and Exceptions tree
View exceptions-tree.php
<?php
if (!function_exists('interface_exists')) {
die('PHP version too old');
}
$throwables = listThrowableClasses();
$throwablesPerParent = splitInParents($throwables);
printTree($throwablesPerParent);
if (count($throwablesPerParent) !== 0) {
die('ERROR!!!');