Skip to content

Instantly share code, notes, and snippets.

🚲
Pedaling

Jérôme Tamarelle GromNaN

Block or report user

Report or block GromNaN

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View apcclearcache.php
<?php
/**
* Clear APC opcode and user caches on deploy
* per directory and prefix.
*
* Store this file in your default APACHE/NGINX root (/home/www/apcclearcache.php)
* Call this file on deployment:
*
* php /home/www/apcclearcache.php <release_dir> <user_cache_prefix>
@GromNaN
GromNaN / base.twig
Last active Aug 29, 2015
Twig issue #1378
View base.twig
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% endblock %}</title>
{% block head %}
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
{% endblock %}
</head>
<body>
{% block header %}{% endblock %}
@GromNaN
GromNaN / gist:10878088
Created Apr 16, 2014
Prophecy vs PHPUnit MockObjects error messages
View gist:10878088

With Prophecy

jtamarelle@ox-dev-php ~/f/lexpress> phpunit tests/Routing/Matcher/ChainMatcherTest.php
PHPUnit 3.7.31 by Sebastian Bergmann.

Configuration read from /space/home/jtamarelle/front/lexpress/phpunit.xml.dist

.E...
View gist:a00965b384fddf9f48c3
<?php
function parseJsonx(\DOMNode $node)
{
switch ($node->nodeName)
{
case 'json:object':
$data = new stdClass();
foreach ($node->childNodes as $childNode) {
if ($childNode instanceof \DOMElement
@GromNaN
GromNaN / .htaccess
Created Jan 6, 2015
Bridge Wordpress & Symfony
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
# Symfony2 URLs begins with app or admin/dashboard
RewriteRule ^app/ app.php [QSA,L]
RewriteRule ^admin/dashboard app.php [QSA,L]
# Others requests are redirected to Wordpress
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
@GromNaN
GromNaN / build.sh
Last active Aug 29, 2015
Split Composer Satis repositories into smaller packages
View build.sh
#!/bin/sh
# For each sub-package, run the Satis build command.
php bin/satis build repositories-mirrors.json ./web/mirrors
php bin/satis build repositories-pear.json ./web/pear
php bin/satis build repositoriesp-rojects.json ./web/projects
# Merge all the package files.
php web/packages.php > web/packages.json
@GromNaN
GromNaN / Update-WP.sh
Created Jan 10, 2011
How-to update WordPress via SSH.
View Update-WP.sh
# Settings
WORDPRESS=/var/www/sites/jerome.tamarelle.net/web/blog
VERSION=3.1
BACKUP=/var/www/sites/jerome.tamarelle.net/backup
# Backup files
BACKUP_NAME=$(command date +"%Y-%m-%d")
mkdir ${BACKUP}
command tar -cjvf "${BACKUP}/${BACKUP_NAME}-files.tar.bz2" ${WORDPRESS}
View SSH connection using RSA key.markdown

If your daily activity requires loging in a lot of Linux systems through SSH, you will be happy to know (if you don't already) that there's a way to allow secure, authenticated remote access, file transfer, and command execution without having to remember passwords for each individual host you connect.

The $HOME/.ssh/authorized_keys file contains the RSA keys allowed for RSA authentication. Each line contains one key, which consists of the following fields: options, bits, exponent, modulus and comment. The first field is optional, bits, exponent and modulus fields give the RSA key and the last field isn't used at all in the authentication process, but it will be somewhat convenient to the user, for instance to know which key is for which machine.

Before we start, make sure your computer has a ssh client installed and the remote Linux system has ssh installed and sshd running, with RSA authentication enabled (RSAAuthentication yes in /etc/ssh/sshd_config).

First, you will need to generate the local RSA key

View mysql.sock.sh
# To solve this issue with XAMPP on Mac:
# PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock)
ln -s /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock /tmp/mysql.sock
View array_flatter.php
<?php
/**
* Convert a multi-dimensions array to a 1 flat array.
*
* @param array $array
* @param string $separator
* @param string $prefix
* @return array
*/
You can’t perform that action at this time.