Skip to content

Instantly share code, notes, and snippets.

View lavoiesl's full-sized avatar

Sébastien Lavoie lavoiesl

View GitHub Profile
@lavoiesl
lavoiesl / fix-permissions.sh
Created March 21, 2012 15:32
setfacl example for Web hosting
#!/bin/bash
# setfacl script for Web hosting
root=/mnt/data
admin_group=admin
users_group=devs
www_user=www-data
# Clear all acls
sudo setfacl -R -b $root/{environments,repositories,common}
@lavoiesl
lavoiesl / wordpress-change-url.php
Last active December 8, 2022 12:09
PHP script to replace site url in Wordpress database dump, even with WPML
#!/usr/bin/env php
<?php
/**
* PHP script to replace site url in Wordpress database dump, even with WPML
* @link https://gist.github.com/lavoiesl/2227920
*/
if (!empty($argv[1]) && $argv[1] == 'update') {
$file = file_get_contents('https://gist.github.com/lavoiesl/2227920/raw/wordpress-change-url.php');
if ($file === false) {
@lavoiesl
lavoiesl / duplicity-backup.sh
Created May 3, 2012 00:44
Very low priority backup using duplicity
#!/bin/bash
# Export some ENV variables so you don’t have to type anything
export AWS_ACCESS_KEY_ID='my-key-id'
export AWS_SECRET_ACCESS_KEY='my-secret'
export PASSPHRASE='my-gpg-key-passphrase'
GPG_KEY='my-gpg-pub-id'
# The source of your backup
SOURCE=/
@lavoiesl
lavoiesl / export-database.sh
Last active December 21, 2015 16:36
Use credentials in /etc/mysql/debian.cnf to export MySQL database
#!/bin/bash
# Use credentials in /etc/mysql/debian.cnf to export MySQL database
database="$1"
shift
options="$@"
if [[ -z "$database" ]]; then
echo "Usage: $0 database [options]" >&2
exit 2
@lavoiesl
lavoiesl / apache-template
Created May 7, 2012 19:24
Apache VirtualHost Template with variable replacement
<VirtualHost *:80>
ServerAdmin {USER}@cslavoie.com
ServerName {DOMAIN}
ServerAlias www.{DOMAIN}
ServerAlias {USER}.localhost
ServerAlias {USER}.static.cslavoie.com
DocumentRoot {DOC_ROOT}
<Directory {DOC_ROOT}>
@lavoiesl
lavoiesl / .htaccess
Created May 17, 2012 22:13
VirtualHost Alias detection in .htaccess
# VirtualHost Alias detection in .htaccess
# https://gist.github.com/2721888
<IfModule mod_rewrite.c>
RewriteEngine On
# Neat trick to rewrite with or without leading slash
# Works by checking if DOCUMENT_ROOT + REQUEST_URI == REQUEST_FILENAME
# If not, it is because you are in a virtual host alias and DOCUMENT_ROOT is not reliable
# Example when alias is active:
@lavoiesl
lavoiesl / remove_crap.sh
Created May 30, 2012 13:05 — forked from anonymous/remove_crap.sh
Remove temporary and junk files from Windows and OS X
#!/bin/bash
#
# Script to remove temporary and junk files from Windows and OS X
#
### Not set up to run as root. Advised not to do this. ###
#### Variables ####
# Files to remove (Add others, just remember to increment the
@lavoiesl
lavoiesl / brew-doctor.log
Created June 11, 2012 14:20
xhprof 0.9.2 on PHP 5.4.3
$ brew doctor
Error: /Library/Frameworks/Mono.framework detected
This can be picked up by CMake's build system and likely cause the build to
fail. You may need to move this file out of the way to compile CMake.
@lavoiesl
lavoiesl / Other infos
Created June 11, 2012 20:50
php54-imagick fails on OSX 10.7.3, PHP 5.4.3
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.9~22/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
$ clang -v
@lavoiesl
lavoiesl / ContactControllerTest.php
Created July 9, 2012 20:11
PHPUnit test for Symfony2 to test email sending
<?php
namespace Acme\DemoBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class ContactControllerTest extends WebTestCase
{
public function testContact() {