Skip to content

Instantly share code, notes, and snippets.

Michele Locati mlocati

Block or report user

Report or block mlocati

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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!!!');
@mlocati
mlocati / php-cs-fixer.cmd
Created Nov 8, 2016
Call php-cs-fixer by automatically locating the configuration file
View php-cs-fixer.cmd
@echo off
setlocal enabledelayedexpansion
if "%~1" equ "" (
echo Missing file name>&2
goto :eof
)
if "%~2" neq "" (
@mlocati
mlocati / compile-php.cmd
Created Oct 7, 2016
Script to compile PHP
View compile-php.cmd
@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 Jun 29, 2019
Enable/disable/check color support for Windows (ENABLE_VIRTUAL_TERMINAL_PROCESSING flag)
View main.c
#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
@mlocati
mlocati / svn2git.sh
Last active Jun 15, 2018
Convert SVN repository to GIT
View svn2git.sh
#!/bin/bash
# This script was written for Ubuntu 14.04 and 16.04
# Other operating systems may need a few changes
WORK_DIR=~/svn2git
AUTHORS_FILE=$WORK_DIR/authors.txt
GITDIR_DIRTY=$WORK_DIR/dirty
GITDIR_FINAL=$WORK_DIR/final
@mlocati
mlocati / fix-git-authors.sh
Last active Jun 28, 2019
Correct wrong email and name in all git commits
View fix-git-authors.sh
#!/bin/bash
WRONG_EMAIL="wrong@email.address"
CORRECT_EMAIL="correct@email.address"
CORRECT_NAME="Correct Name"
git filter-branch --env-filter '
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]; then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]; then
@mlocati
mlocati / win10colors.cmd
Last active Oct 20, 2019
ANSI Colors in standard Windows 10 shell
View win10colors.cmd
@echo off
cls
echo  STYLES 
echo ^<ESC^>[0m Reset
echo ^<ESC^>[1m Bold
echo ^<ESC^>[4m Underline
echo ^<ESC^>[7m Inverse
echo.
echo  NORMAL FOREGROUND COLORS 
echo ^<ESC^>[30m Black (black)
You can’t perform that action at this time.