Skip to content

Instantly share code, notes, and snippets.

@maximevalette
maximevalette / apache2.conf
Created December 12, 2010 12:06
My /etc/apache2/apache2.conf
### Section 1: Global Environment
ServerRoot "/etc/apache2"
LockFile /var/lock/apache2/accept.lock
PidFile /var/run/apache2.pid
Timeout 100
KeepAlive Off
MaxKeepAliveRequests 200
KeepAliveTimeout 4
ServerLimit 256
@maximevalette
maximevalette / gist:754421
Created December 24, 2010 17:49
Replace a string in multiple files at once
for i in `find . -name '*.txt'`; do vim -c "%s/toreplace/replaced/g | x" "$i"; done
@maximevalette
maximevalette / gist:758937
Last active September 24, 2015 13:58
Slugify string
<?php
function urlcompliant($nompage) {
$a = array('À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','Ø','Ù','Ú','Û','Ü','Ý','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ñ','ò','ó','ô','õ','ö','ø','ù','ú','û','ü','ý','ÿ','A','a','A','a','A','a','C','c','C','c','C','c','C','c','D','d','Ð','d','E','e','E','e','E','e','E','e','E','e','G','g','G','g','G','g','G','g','H','h','H','h','I','i','I','i','I','i','I','i','I','i','','','J','j','K','k','L','l','L','l','L','l','','','L','l','N','n','N','n','N','n','','O','o','O','o','O','o','Œ','œ','R','r','R','r','R','r','S','s','S','s','S','s','Š','š','T','t','T','t','T','t','U','u','U','u','U','u','U','u','U','u','U','u','W','w','Y','y','Ÿ','Z','z','Z','z','Ž','ž','','ƒ','O','o','U','u','A','a','I','i','O','o','U','u','U','u','U','u','U','u','U','u','','','','','','','€','@','Š','¡');
$b = array('A','A','A','A','A','A','AE','C','E','E','E','E','I','I','I','I','D','N','O','O','O','O','O','O','U','U','U
@maximevalette
maximevalette / call.pl
Created January 30, 2011 10:39
SIP Call in Perl
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long qw(:config posix_default bundling);
use Net::SIP;
#Usage
sub usage {
@maximevalette
maximevalette / xdebug.ini
Created March 12, 2011 19:11
PHP Xdebug configuration file
xdebug.remote_enable = 1
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.idekey = "tacrukjallaistefilermonide"
xdebug.remote_connect_back = 1
@maximevalette
maximevalette / client.conf
Created March 14, 2011 09:21
OpenVPN basic client.conf
# EDIT:
# IP PORT
# ca.crt
# client.crt
# client.key
client
dev tap
proto tcp
remote IP PORT
@maximevalette
maximevalette / getLanguage.php
Created March 16, 2011 10:05
Retourne la langue préférée du navigateur.
<?php
/**
* Retourne la langue préférée du navigateur.
*
* @return string
*/
function getLanguage() {
@maximevalette
maximevalette / cache.php
Created March 16, 2011 11:55
Fonctions pour gérer un memcache facilement avec MySQL
<?php
/**
* Exemple de variables Memcache
* Il faut absolument configurer le common name, pour pas faire de collision entre données
* si on a plusieurs sites avec le même Memcache.
*/
$memcache = new Memcache();
$memcache->addServer('localhost',9000);
@maximevalette
maximevalette / xhrdie.php
Created April 6, 2011 14:33
Allow scripts to "die" following the HTTP Request type (AJAX or not)
<?php
/**
* Allow scripts to "die" following the HTTP Request type (AJAX or not)
* @param $msg Message to send if sent through AJAX
* @return void
*/
function xhrDie($msg) {
$headers = apache_request_headers();
@maximevalette
maximevalette / xmljson.php
Created April 18, 2011 11:56
Un snippet pour sortir un tableau
<?php
/**
* @var array $data Le tableau qu'on veut sortir en XML ou JSON(P)
* @var (xml|json) $format Le format de sortie désiré
* @var string $callback Le nom de la fonction à appeler si on veut faire du JSONP
*/
$data = array();
$format = 'xml';