Skip to content

Instantly share code, notes, and snippets.

View ronanguilloux's full-sized avatar

Ronan Guilloux ronanguilloux

View GitHub Profile
@ronanguilloux
ronanguilloux / pre-commit
Last active May 16, 2024 09:29 — forked from cjsaylor/pre-commit
phplint + phpcs + php-cs-fixer PHP-related pre-commit git hook (needs to add squizlabs/php_codesniffer & fabpot/php-cs-fixer to your composer.json)
#!/bin/sh
# @source: https://gist.github.com/ronanguilloux/11f6a788358577474ab4
# @link http://tech.zumba.com/2014/04/14/control-code-quality/
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
# Determine if a file list is passed
@ronanguilloux
ronanguilloux / MSWordHtmlCleaners.js
Created June 12, 2012 07:56
2 js solutions to clean nasty MS Word HTML pasted in any CMS + 2 server-side tips
var CleanWordHTML = function ( str )
{
str = str.replace(/<o:p>\s*<\/o:p>/g, "") ;
str = str.replace(/<o:p>.*?<\/o:p>/g, "&nbsp;") ;
str = str.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ;
str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ;
str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
str = str.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ;
str = str.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
str = str.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
@ronanguilloux
ronanguilloux / script-bash-redmine-backups
Last active September 17, 2021 06:32 — forked from gabrielkfr/script-bash-redmine-backups
Backup script (daily & monthly) for Redmine (full instance + db sql snapshot)
#! /bin/bash
#
# backup_redmine.sh
# modified by ronan@lespolypodes.com
# Inspiration: https://gist.github.com/gabrielkfr/6432185
#
# Distributed under terms of the MIT license.
# -- VARS
DAY=`date +"%Y%m%d"`
@ronanguilloux
ronanguilloux / slugify.sh
Last active April 25, 2021 07:17
batch in bash to replace accents in filenames
#! /bin/bash
#
# slugify.sh by Ronan
#
# Distributed under terms of the MIT license.
#
cd photos
for file in *.png; do
filename=${file%.*}
@ronanguilloux
ronanguilloux / akeneo.batch.job.md
Created November 10, 2015 17:02
akeneo:batch:job
~/pim$ php app/console akeneo:batch:job --help
Usage:
  akeneo:batch:job [options] [--] <code> [<execution>]

Arguments:
  code                     Job instance code
  execution                Job execution id

Options:
@ronanguilloux
ronanguilloux / ProductBlockService.php
Created September 30, 2014 13:29
Associate a Custom Sonata Admin Class to a Sonata Block Service
<?php
namespace Application\Sonata\PageBundle\Block\Service;
use Sonata\BlockBundle\Block\BlockContextInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
#!/bin/bash
# disk-usage from docker-experiments
# https://github.com/rsp/docker-experiments
# by Rafał Pocztarski - https://github.com/rsp
if [ $# -ne 1 ]; then
echo "Usage: $0 \"image1 image2 ...\""
exit 1
fi
@ronanguilloux
ronanguilloux / gist:5317541
Last active February 21, 2018 19:07 — forked from i556/gist:1661623
//parent.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script type="text/javascript">
window.addEventListener("message", receiveSize, false);
function receiveSize(e) {
//console.log("parent: message received", e);
@ronanguilloux
ronanguilloux / akeneo-pim-ce-install.sh
Last active June 26, 2017 19:55
Akeneo PIM CE install script
#! /bin/bash
#
# install.sh
# Distributed under terms of the MIT license.
# Usage: $ install.sh
# Need a github-oauth.github.com in your global composer conf
LAST_TAG_NAME=$(curl -s https://api.github.com/repos/akeneo/pim-community-standard/tags | python -c 'import sys, json; print json.load(sys.stdin)[0]["name"]')
LAST_TAG_URL=$(curl -s https://api.github.com/repos/akeneo/pim-community-standard/tags | python -c 'import sys, json; print json.load(sys.stdin)[0]["zipball_url"]')
CURL_URL=$LAST_TAG_URL?access_token=$GITHUB_TOKEN
@ronanguilloux
ronanguilloux / georss.js
Created April 21, 2013 22:08
GeoRSS (XML with go:lat, geo;long nodes) jQuery parsing, with performances improvements
$.fn.filterNode = function(name) {
return this.find('*').filter(function() {
return this.nodeName === name;
});
};
// example: 'http://www.emsc-csem.org/service/rss/rss.php?typ=emsc&min_lat=10&min_long=-30&max_long=65';
// (EMSC - Last 50 earthquakes in euro mediteranean region)
function handleRSS(url) {
$.ajax({