Skip to content

Instantly share code, notes, and snippets.

View mlocati's full-sized avatar

Michele Locati mlocati

View GitHub Profile
@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
);
@mlocati
mlocati / Enable-HyperV.ps1
Last active July 30, 2020 16:23
Enable or disable Hyper-V (to switch between VirtualBox and Docker for Windows, for example)
<#
To enable Hyper-V:
Enable-HyperV.ps1 $True
To disable Hyper-V:
Enable-HyperV.ps1 $False
Author: Michele Locati <[email protected]>
License: MIT
Source: https://gist.github.com/mlocati/bb146577785511b44412e2fb57f969a6
#>
@mlocati
mlocati / app.php
Last active August 25, 2022 20:52
Install concrete5 on Android (Termux)
<?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 January 23, 2019 09:35
Check if a go-pear.phar file is an official one
#!/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 <[email protected]> on 2019-01-23
set -o errexit
set -o nounset
@mlocati
mlocati / output.html
Last active March 15, 2017 15:45
Punic units
<!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 March 9, 2017 10:58
Throwable and Exceptions tree
<?php
if (!function_exists('interface_exists')) {
die('PHP version too old');
}
$throwables = listThrowableClasses();
$throwablesPerParent = splitInParents($throwables);
printTree($throwablesPerParent);
if (count($throwablesPerParent) !== 0) {
die('ERROR!!!');
@mlocati
mlocati / php-cs-fixer.cmd
Created November 8, 2016 20:12
Call php-cs-fixer by automatically locating the configuration file
@echo off
setlocal enabledelayedexpansion
if "%~1" equ "" (
echo Missing file name>&2
goto :eof
)
if "%~2" neq "" (
@mlocati
mlocati / compile-php.cmd
Created October 7, 2016 08:10
Script to compile PHP
@echo off
setlocal enabledelayedexpansion
rem Reference: https://wiki.php.net/internals/windows/stepbystepbuild
set MY_VSDIR=C:\Path\To\Microsoft Visual Studio 14.0
set PATH=%SystemRoot%\System32
echo # Compiling PHP
@mlocati
mlocati / main.c
Last active January 19, 2024 14:10
Enable/disable/check color support for Windows (ENABLE_VIRTUAL_TERMINAL_PROCESSING flag)
#define _WIN32_WINNT 0x0600
#include <stdio.h>
#include <windows.h>
#include <fileapi.h>
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif