Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mlocati's full-sized avatar

Michele Locati mlocati

View GitHub Profile
@mlocati
mlocati / remove-old-kernel-versions.php
Last active August 29, 2015 14:03
Remove old kernel versions, by keeping only the active one and the latest one
#!/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':
@mlocati
mlocati / translate-countries.js
Last active June 16, 2016 09:57
Translate Country names for Webogram
/* 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 / concrete5.md
Created December 24, 2015 11:03
concrete5 under nginx

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 / 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 / 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 <michele@locati.it> on 2019-01-23
set -o errexit
set -o nounset
@mlocati
mlocati / fix-git-authors.sh
Last active June 28, 2019 14:25
Correct wrong email and name in all git commits
#!/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 / svn2git.sh
Last active December 20, 2019 14:46
Convert SVN repository to GIT
#!/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 / 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 / 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 <michele@locati.it>
License: MIT
Source: https://gist.github.com/mlocati/bb146577785511b44412e2fb57f969a6
#>