Skip to content

Instantly share code, notes, and snippets.

View pascalchevrel's full-sized avatar

Pascal Chevrel pascalchevrel

View GitHub Profile
@pascalchevrel
pascalchevrel / gist:0df93484a5031b533a38
Created October 15, 2014 13:12
.bashrc alias to show remote git branches
alias git_show_remote=git_show_remote
function git_show_remote()
{
for k in `git branch -r | perl -pe 's/^..(.*?)( ->.*)?$/\1/'`; do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k -- | head -n 1`\\t$k; done | sort -r
}
@pascalchevrel
pascalchevrel / gist:cd8f9841ea0a8df09722
Last active August 29, 2015 14:07
List the number of locales per Firefox release
<?php
$connect = ftp_connect('ftp.mozilla.org');
$login = ftp_login($connect, 'anonymous', '');
$versions = [
'1.0', '1.5', '2.0', '3.0', '3.5', '3.6', '4.0', '5.0', '6.0', '7.0', '8.0',
'9.0','10.0', '11.0', '12.0', '13.0', '14.0.1', '15.0', '16.0', '17.0', '18.0',
'19.0','20.0', '21.0', '22.0', '23.0', '24.0', '25.0', '26.0', '27.0', '28.0',
'29.0','30.0', '31.0', '32.0',
@pascalchevrel
pascalchevrel / gist:ac14647e3ee30fce955c
Last active August 29, 2015 14:12
Calculate length of "Happy new year" in many locales
<?php
mb_internal_encoding('UTF-8');
$message = [
'ar' => 'عام سعيد',
'bn-IN' => 'শুভ নববর্ষ!',
'ca' => 'Bon any nou',
'cs' => 'Štastný nový rok!',
'cy' => 'Blwyddyn newydd dda!',
'de' => 'Frohes neues Jahr!',
<?php
$history['sub'] = 'beta';
$hosts = [
0 => [
'foo' => 0,
'bar' => 1
],
1 => [
@pascalchevrel
pascalchevrel / gist:052f0dadba4ffabe86c2
Last active August 29, 2015 14:21
Redirections billets blog.mozfr.org vers firefoxos.mozfr.org
RewriteEngine on
RewriteBase /
# Migration des billets du blog principal vers le blog FirefoxOS
RewriteRule ^(post/2015/05/Ce-qui-a-etonne-AmarOk-en-rejoignant-le-groupe-comm-pour-Firefox-OS-et-Mozilla)$ https://firefoxos.mozfr.org/$1 [L,R=301]
RewriteRule ^(post/2015/04/Mamie-Fox-fait-des-cookies-3D)$ https://firefoxos.mozfr.org/$1 [L,R=301]
RewriteRule ^(post/2015/05/Philippe-a-aussi-participe-au-futur-de-Firefox-OS)$ https://firefoxos.mozfr.org/$1 [L,R=301]
RewriteRule ^(post/2015/05/Firefox-OS-dans-la-presse-en-avril)$ https://firefoxos.mozfr.org/$1 [L,R=301]
RewriteRule ^(post/2015/04/Naissance-Firefox-pour-Android-29-mars-2011)$ https://firefoxos.mozfr.org/$1 [L,R=301]
@pascalchevrel
pascalchevrel / functests.php
Last active August 29, 2015 14:22
Functional regression tests for the Stores l10n API between 1.0 and 2.0 of the app
<?php
namespace Verif;
class Verif
{
protected $host;
public $target;
protected $content = false;
protected $status = 0;
@pascalchevrel
pascalchevrel / class.dc.piwik.php
Last active August 29, 2015 14:24
Modif du code du plugin Piwik pour Dotclear
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of Dotclear 2.
#
# Copyright (c) 2003-2008 Olivier Meunier and contributors
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
@pascalchevrel
pascalchevrel / gist:27442f9bb5119caf2b76
Last active October 12, 2015 12:31
Cherry pick commit from local another local repository (used for bedrock-l10n production)
# Bedrock prod commit cherry-pick
commit() {
cd /home/pascalc/repos/github/bedrock-l10n
git --git-dir=../www.mozilla.org/.git format-patch -k -1 --stdout $1 | git apply
}
# example use: commit 27c3da077cb8ba3b4b048307bfd514700571578d
@pascalchevrel
pascalchevrel / patchy.txt
Created January 20, 2016 10:52
A bash function to put in your .bash_aliases to send the diff of your repo (hg, git svn…) to a remote 'patches' folder that you make web accessible for sharing
function patchy()
{
tmp='/tmp/diff_being_sent_to_your_server'
$1 diff > $tmp
scp $tmp john@doe.com:/home/john/patches/$2.diff
rm $tmp
}
<?php
/**
* Return the current URL with the json GET variable appended
* This is used on views which also exist in our public API
* https://github.com/mozfr/transvision/wiki/JSON-API
*
* @param boolean $swap_locales Defaults to False. If set to True, swap the
* values of locale and source_locale parameters.
* @return string URL with 'json' appended as part of the query string
*/