Skip to content

Instantly share code, notes, and snippets.

View GregoireHebert's full-sized avatar
:octocat:
Probably somewhere sipping a beer

Grégoire Hébert GregoireHebert

:octocat:
Probably somewhere sipping a beer
View GitHub Profile
@GregoireHebert
GregoireHebert / mysqlsesslock
Created November 25, 2013 20:40
Custom handler, mysql, one row per session, with a mysql advisory lock per session and per var. the "standard" session handler one would write to store session data in a MySQL database. Each row stores the data for one session, the serialized session data is stored in a field of type text. Before the session is read, a mysql advisory lock is acq…
<?php
/* ------------------------------------------------------------------------
* session_mysql.php
* ------------------------------------------------------------------------
* PHP4 MySQL Session Handler
* Version 1.00
* by Ying Zhang (ying@zippydesign.com)
* Last Modified: May 21 2000
* Modified in 2006 by Andy Bakun (abakun ! thwartedefforts , org) to
@GregoireHebert
GregoireHebert / icsGenerator.php
Last active December 30, 2015 05:59
Méthode de génération de l'identifiant créditeur SEPA
/**
* Génère l'identifiant créditeur SEPA à partir du Numéro National Emetteur à partir de la méthode de calcul de l'EPC (http://www.europeanpaymentscouncil.eu/content.cfm?page=sepa_direct_debit_%28sdd%29).<br/>
* Les identifiants Créditeurs SEPA sont attribué par la banque de france. Seuls les créditeurs ayant un compte dans une banque française
* peut faire la demande d'un identifiant de créditeur. La demande doit être faite auprès de la banque de france par l'établissement bancaire du créditeur.
* Cet établissement doit avoir un accord avec le conseil européen des paiements.
* (France métropolitaine, Guyane Française, Guadeloupe, Martinique, Mayotte, Réunion, Saint Barthélemy, Saint Martin, Saint Pierre et Miquelon)
* @param string $numero_national_emetteur Identifiant de l'émetteur sur maximum 27 caratères. Est composé de caractères alphanumériques.
* @param string $pays Identifiant du pays au format iso. (http://www.iso.org/iso/fr/french_country_names_and_code_elements.htm) (par défa
<?php
// Security permissions:
$writePost = 1;
$readPost = 2;
$deletePost = 4;
$addUser = 8;
$deleteUser = 16;
// User groups:
@GregoireHebert
GregoireHebert / .bashrc
Created August 5, 2015 10:01
Custom ~/.bashrc with some aliases
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
@GregoireHebert
GregoireHebert / .gitconfig
Last active April 10, 2020 07:59
Custom ~/.gitconfig
[user]
name = Grégoire Hébert
email = gregoire@les-tilleuls.coop
[core]
excludesfile = /Users/gheb/.gitignore_global
[difftool]
prompt = false
[color]
branch = auto
status = auto
@GregoireHebert
GregoireHebert / debian-8-redmine-procedure.txt
Last active August 28, 2015 09:35
A debian 8 Jessie Installation procedure (written as bash but not made to be executed)
# NOTES #
# Installation available for a debian 8
# Ensure you got root privileges
# Installation of Apache, php, mysql, curl, subversion
apt-get install mysql-server mysql-common libmysqlclient-dev mysql-client apache2 apache2-mpm-prefork apache2-prefork-dev libapr1-dev libaprutil1-dev libfcgi-dev libssl-dev zlib1g-dev libcurl4-openssl-dev phpmyadmin imagemagick libmagickwand-dev php5 libapache2-mod-php5 php5-mysql php5-ldap php5-imagick php5-curl php5-gd php5-intl php-pear php5-imap php5-mcrypt php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl php-apc curl subversion
# Installation of Ruby
apt-get install gcc build-essential zlib1g zlib1g-dev libssl-dev libyaml-dev libcurl4-openssl-dev libapr1-dev libxslt-dev checkinstall libffi-dev libreadline-dev git-core
@GregoireHebert
GregoireHebert / import-export-mongo.sh
Last active August 31, 2015 16:33
Import export script for mongo
#!/bin/bash
LOADING=false
usage()
{
cat << EOF
usage: $0 [options] dbname
OPTIONS:
@GregoireHebert
GregoireHebert / create_gitlab_project.sh
Last active August 2, 2016 12:58
Script to create a virtualhost + directory + gitlab project + capistrano deployement + webhook
#!/bin/bash
# create_gitlab_project.sh
# create_gitlab_project.sh: shell script that create a virtualhost + directory + gitlab project + capistrano deployement + webhook.
# The MIT License (MIT)
# Copyright (C) 2015 Grégoire Hébert http://www.gheb.fr
# Permission is hereby granted, free of charge, to any person obtaining a copy
@GregoireHebert
GregoireHebert / recap.txt
Created November 5, 2015 10:17
Récapitulatif du script de création de projet
Cet outil va réaliser les opérations suivantes :
1) Création d'un répertoire http
2) Ajout d'un virtualhost
3) Création d'un nouveau projet sur GITLAB
4) Initialiser le dépôt
5) Configurer le déploiement automatique
6) Déployer le projet une première fois
@GregoireHebert
GregoireHebert / DotenvUpdater
Last active November 6, 2018 17:14
DotenvUpdater
#!/usr/bin/env php
<?php
declare(strict_types=1);
foreach ([__DIR__ . '/../../../autoload.php', __DIR__ . '/../vendor/autoload.php'] as $file) {
if (file_exists($file)) {
require $file; break;
}
}