Skip to content

Instantly share code, notes, and snippets.

Avatar

Michele Locati mlocati

View GitHub Profile
@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 / svn2git.sh
Last active Dec 20, 2019
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 / 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 / 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 / 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 / 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 / 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 / concrete5.md
Created Dec 24, 2015
concrete5 under nginx
View concrete5.md

Here's a very basic nginx configuration for a website running concrete5:

# Define the server configuration
server {
	# Define the ports the server is listening to
	# In case this is the default website, you can add default_server before the semicolon
	listen 80;
	listen [::]:80 ipv6only=on;
@mlocati
mlocati / translate-countries.js
Last active Jun 16, 2016
Translate Country names for Webogram
View translate-countries.js
/* A little utility to translate Country names for Webogram.
* You need to install nodejs.
* Usage: node <thisfile> <languageCode> <inputFile> [outputFile]
* If outputFile is not specified, inputFile will be overwritten.
*
* @author: Michele Locati <mlocati@gmail.com>
* @licence: MIT
*/
try {
var fs = require('fs'), path = require('path');
@mlocati
mlocati / remove-old-kernel-versions.php
Last active Aug 29, 2015
Remove old kernel versions, by keeping only the active one and the latest one
View remove-old-kernel-versions.php
#!/usr/bin/php
<?php
try {
$doEcho = true;
$action = 'view';
if(isset($argv) && is_array($argv) && (count($argv) == 2)) {
$action = strtolower($argv[1]);
switch($action) {
case 'view':
case 'simulate':