Skip to content

Instantly share code, notes, and snippets.

@radicaldingos
radicaldingos / Vagrantfile
Last active April 10, 2024 15:13
Example of Vagrantfile with config stored in an external YAML file. It looks for a "vagrant.yml.dist" file, which can be overloaded by a "vagrant.yml".
# encoding: utf-8
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'yaml'
# Load settings from vagrant.yml or vagrant.yml.dist
current_dir = File.dirname(File.expand_path(__FILE__))
if File.file?("#{current_dir}/vagrant.yml")
config_file = YAML.load_file("#{current_dir}/vagrant.yml")
@radicaldingos
radicaldingos / strip_accents.php
Created October 28, 2015 15:33
Function to strip accents of a string
<?php
/**
* Fonction permettant de se débarrasser des accents dans une chaîne de caractères,
* en les remplaçant par la lettre correspondante
*
* @param string $string Chaîne à nettoyer
*
* @return string Chaîne débarrassée d'accents
*/
@radicaldingos
radicaldingos / varsize.php
Last active October 28, 2015 15:28
Function to determine the memory footprint of a PHP variable or object
<?php
/**
* Conversion d'un nombre d'octets en une taille lisible
*
* @param int $size Taille en octets
*
* @return string Taille lisible
*/
function convertSize($size)
@radicaldingos
radicaldingos / debug.php
Created October 9, 2015 20:41
Simple and useful debugging function
<?php
/**
* Fonction de débuggage
*
* Permet d'arrêter l'exécution du script et d'afficher le contenu d'une
* variable.
*
* @param mixed $objet Variable à afficher
* @param boolean $detail TRUE pour afficher un var_dump, FALSE pour print_r