Skip to content

Instantly share code, notes, and snippets.

View GromNaN's full-sized avatar
🚲
☀️

Jérôme Tamarelle GromNaN

🚲
☀️
View GitHub Profile
@GromNaN
GromNaN / composer.json
Created July 20, 2020 21:12
Autoload error handler
{
"name": "<to-be-defined>",
"type": "library",
"license": "MIT",
"autoload": {
"files": [ "handler.php" ]
}
}
@GromNaN
GromNaN / Update-WP.sh
Created January 10, 2011 23:50
How-to update WordPress via SSH.
# Settings
WORDPRESS=/var/www/sites/jerome.tamarelle.net/web/blog
VERSION=3.1
BACKUP=/var/www/sites/jerome.tamarelle.net/backup
# Backup files
BACKUP_NAME=$(command date +"%Y-%m-%d")
mkdir ${BACKUP}
command tar -cjvf "${BACKUP}/${BACKUP_NAME}-files.tar.bz2" ${WORDPRESS}
@GromNaN
GromNaN / async-aws-dynamodb.php
Last active March 25, 2020 22:28
Trying async-aws/dynamodb
<?php
namespace Testing;
use AsyncAws\DynamoDb\DynamoDbClient;
require __DIR__.'/vendor/autoload.php';
$dynamodbClient = new DynamoDbClient(['region' => 'eu-west-1']);
try {
@GromNaN
GromNaN / detect-utf8.php
Created December 1, 2011 22:54
How to detect UTF-8 string in PHP
<?php
function isUtf8($string)
{
return preg_match('%(?:'
. '[\xC2-\xDF][\x80-\xBF]' // non-overlong 2-byte
. '|\xE0[\xA0-\xBF][\x80-\xBF]' // excluding overlongs
. '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}' // straight 3-byte
. '|\xED[\x80-\x9F][\x80-\xBF]' // excluding surrogates
. '|\xF0[\x90-\xBF][\x80-\xBF]{2}' // planes 1-3
@GromNaN
GromNaN / build.sh
Last active July 11, 2019 16:08
Split Composer Satis repositories into smaller packages
#!/bin/sh
# For each sub-package, run the Satis build command.
php bin/satis build repositories-mirrors.json ./web/mirrors
php bin/satis build repositories-pear.json ./web/pear
php bin/satis build repositoriesp-rojects.json ./web/projects
# Merge all the package files.
php web/packages.php > web/packages.json
@GromNaN
GromNaN / conversion.html
Last active January 2, 2018 15:56
CSV conversion
<html>
<head>
<style type="text/css">
textarea {
width: 100%;
height: 300px;
}
</style>
<script type="text/javascript" src="http://papaparse.com/resources/js/papaparse.js"></script>
<script type="text/javascript" src="conversion.js"></script>
@GromNaN
GromNaN / README.md
Last active February 11, 2017 19:17 — forked from andris9/README.md
Extremely simple HTTP proxy for changing Host: header Useful when proxying requests to virtual hosts that require Host: header to be set.

Setup reverse tunnel

Run the following in your client machine

ssh -R EXPOSED_PORT:localhost:SERVICE_PORT USER@HOST

Where

  • EXPOSED_PORT is the port exposed to the internet in the proxy server
  • SERVICE_PORT is the port your application is listening in your machine
@GromNaN
GromNaN / GraphvizContainerCommand.php
Last active January 20, 2017 21:27
Graphviz Symfony container
<?php
namespace AppBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@GromNaN
GromNaN / e107-to-joomla.sql
Last active August 31, 2016 23:11
Users and Forum migration from e107 to Joomla+Kunena
SET character_set_client = utf8mb4;
SET character_set_connection = utf8mb4;
DELIMITER $$
DROP FUNCTION IF EXISTS HTML_UnEncode$$
CREATE DEFINER=`root`@`localhost` FUNCTION `HTML_UnEncode`(x VARCHAR(16383)) RETURNS varchar(16383) CHARSET utf8mb4
BEGIN
DECLARE TextString VARCHAR(16383);
@GromNaN
GromNaN / rollbar-resolve-items.php
Created March 14, 2016 12:27
Rollbar : Find and resolve items using the API
<?php
$term = 'This resource is not routable';
$read_access_token = '<READ ACCESS TOKEN>';
$write_access_token = '<WRITE ACCESS TOKEN>';
$total = 0;
do {