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
@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
*/
View fabfile.py
from fabric.api import *
"""
Base configuration
"""
env.project_name = '$(project)'
env.database_password = '$(db_password)'
env.site_media_prefix = "site_media"
env.admin_media_prefix = "admin_media"
env.newsapps_media_prefix = "na_media"
@GromNaN
GromNaN / TempDir.php
Created Jun 22, 2011
Temporary directory deleted when PHP ends.
View TempDir.php
<?php
/**
* Temporary directory deleted when PHP ends.
*
* @author Jérôme Tamarelle <jerome@tamarelle.net>
*/
final class TempDir
{
private static $instances = array();
View gist:1342799
# Find the process ID
ps -ax | grep Safari
# Pause the process
kill -STOP 1234
# Resume the process
kill -CONT 1234
@GromNaN
GromNaN / Doctrine_Connection_Mssql.php
Created Nov 10, 2011
Doctrine_Connection_Mssql with optimized modifyLimitQuery()
View Doctrine_Connection_Mssql.php
<?php
/*
* $Id: Mssql.php 5804 2009-06-02 19:52:42Z jwage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
@GromNaN
GromNaN / autoload.php
Created Nov 29, 2011
PSR-0 autoload.php
View autoload.php
<?php
/**
* Simple autoloader that follow the PHP Standards Recommendation #0 (PSR-0)
* @see https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md for more informations.
*
* Code inspired from the SplClassLoader RFC
* @see https://wiki.php.net/rfc/splclassloader#example_implementation
*/
spl_autoload_register(function($className) {
@GromNaN
GromNaN / detect-utf8.php
Created Dec 1, 2011
How to detect UTF-8 string in PHP
View detect-utf8.php
<?php
function isUtf8($string)
{
return preg_match('%(?:'
. '[\xC2-\xDF][\x80-\xBF]' // non-overlong 2-byte
. '|\xE0[\xA0-\xBF][\x80-\xBF]' // excluding overlongs
. '|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}' // straight 3-byte
. '|\xED[\x80-\x9F][\x80-\xBF]' // excluding surrogates
. '|\xF0[\x90-\xBF][\x80-\xBF]{2}' // planes 1-3
You can’t perform that action at this time.