Skip to content

Instantly share code, notes, and snippets.

@guelau
guelau / bashrc
Last active July 1, 2019 09:55
My .bashrc add on
# User specific aliases and functions
# @VAR
KUBE_NS_PREPROD="preprodns"
KUBE_NS_DEV="devns"
KUBE_NS_PROD="prodns"
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
@guelau
guelau / Recursive rmdir
Last active December 22, 2015 01:38
Recursive rmdir
<?php
function rmdir_r ($d)
{
if (is_dir ($d)) {
$list = scandir ($d);
foreach ($list as $object) {
if ($element != '.' && $element != '..') {
if (is_dir ($d . '/' . $element)) {
rmdir_r ($d . '/' . $element);
@guelau
guelau / __mergetool.sh
Created April 23, 2014 22:02
This script get PHP gettext string (finds the "__" function) and merges them in .po files.
#!/bin/bash
XGETTEXT=/usr/bin/xgettext
XMESGMERG=/usr/bin/msgmerge
DOMAIN="messages.po"
TEMPLATE="messages.pot"
if [ ! -e "$1" ]; then
touch $1
@guelau
guelau / vimrc
Last active August 29, 2015 14:08
My personal vimrc
"""""""""""""""""""""""""""""""""""""
" GENERAL
"""""""""""""""""""""""""""""""""""""
set nocompatible
set history=500
" undo, pour revenir en arrière
set undolevels=150
" vim monitor realtime changes to a file
@guelau
guelau / checkwhois.sh
Last active August 29, 2015 14:09
Check the domaine name status and send an email when "domain-name" is entered redemption period
#!/bin/bash
DOMAIN_NAME=$1
MAIL=$2
if [ "x$2" = "x" ]; then
echo "Usage: $0 domain-name.ltd email-adress";
echo "Example: $0 example.com my.email@example.com"
exit;
fi
@guelau
guelau / install-php-tools
Last active July 11, 2016 21:31
Usefull when I install a new development environment
#!/bin/bash
BIN_DIR="/usr/bin"
DOWNLOAD_SCRIPTS=(
"https://phar.phpunit.de/phpcpd.phar"
"https://phar.phpunit.de/phpunit.phar"
"https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar"
"http://phpdox.de/releases/phpdox.phar"
"http://static.pdepend.org/php/latest/pdepend.phar"
@guelau
guelau / .gitconfig
Last active November 14, 2018 10:46
[user]
name = Laurent Guédon
email = laurent@privatemail.com
[alias]
amend = commit --amend
st = status
df = diff
co = checkout
ci = commit
@guelau
guelau / hophop
Created March 10, 2016 08:01
New environment?
#!/bin/bash
mkdir .config && cd .config
git clone https://gist.github.com/5765391.git bashrc
echo -e "\nsource `pwd`/bashrc/bashrc\n" >> ~/.bashrc
cd ..
git clone https://gist.github.com/d2b6ccc2c5bb3dd0fdbc.git vimrc
ln -sf ~/.config/vimrc ~/.vimrc
@guelau
guelau / default.vcl
Last active November 14, 2018 10:46
Varnish Check
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
if (req.http.host ~ "^cdn\.myapiservice\.com") {
set req.http.host = "api.myapiservice.com";
set req.url = regsub(req.url, "^/", "/v1/images/");
}
@guelau
guelau / s3cmd-cache
Last active July 11, 2016 21:29
Adding Cache-Control to all objects of a bucket/directory
s3cmd modify --add-header='Cache-Control: max-age=2419200, must-revalidate' s3://BUCKET/dir/path --recursive