Skip to content

Instantly share code, notes, and snippets.

View juliendufresne's full-sized avatar

Julien Dufresne juliendufresne

  • Paris
View GitHub Profile
@juliendufresne
juliendufresne / output.sh
Last active August 20, 2017 14:26
Formatted output in bash
function title()
{
header '=' "${1:-}"
}
function section()
{
header '-' "${1:-}"
}
@juliendufresne
juliendufresne / .gitconfig
Created March 2, 2017 20:04
Mon .gitconfig (version non maintenue à jour)
[alias]
###
### branch
###
b = branch --all
###
### checkout
###
co = checkout
@juliendufresne
juliendufresne / import_mysql_table_from_symfony.sh
Created March 2, 2017 19:55
Import sql(.gz) table dump into database and filter table according to symfony doctrine project
#!/usr/bin/env bash
#
# Import sql and/or sql.gz table dump into database
#
# This script looks will import table defined in a symfony/doctrine project directory
# with mapping define with annotation.
# please consider using the --help option to read more about all the options available.
#
#
@juliendufresne
juliendufresne / pre-commit.php-cs-fixer
Created December 24, 2016 22:35
pre-commit php-cs-fixer hook using vagrant
#!/usr/bin/env bash
# Note: the file must be named pre-commit, be executable and be located in .git/hooks/
echo "php-cs-fixer pre commit hook start"
# This pre-commit check if the files that are going to be committed suits our coding style
# The commit will fail when this happens.
#
# We could try to automatically fix files include in the commit
# BUT there are some special cases that makes it impossible to be totally safe/
@juliendufresne
juliendufresne / symfony_check_parameters.rb
Created September 29, 2016 15:41
Capistrano task - checks parameters.yml keys against parameters.yml.dist
namespace :symfony do
desc "Check if shared parameters.yml is in sync with release parameters.yml.dist"
task :check_parameters, :except => { :no_release => true } do
puts "--> <symfony:check_parameters>"
distParameters = YAML::load(capture("cat #{release_path}/app/config/parameters.yml.dist"))
invoke_command("if [ -f '#{shared_path}/app/config/parameters.yml' ]; then echo -n 'true'; else echo -n 'false'; fi") do |ch, stream, out|
if out != 'true'
@juliendufresne
juliendufresne / mysql_import_dump.sh
Last active August 29, 2016 15:41
Import MySQL dump from a folder containing one file.sql.gz per table
#!/bin/bash
# Import a dump folder to a database
# Will remove the table, view and trigger just before importing each table
# Where is located your dumps.
# The folder must contain one file per table and must use the .sql.gz extension
DUMP_FOLDER="$1"
@juliendufresne
juliendufresne / install_ansible.sh
Last active July 19, 2016 02:16
Install latest ansible from source in debian
#!/usr/bin/env bash
sudo apt-get install -y python-setuptools python-dev libffi-dev libssl-dev sshpass
sudo easy_install pip
sudo pip install paramiko PyYAML Jinja2 httplib2 six
cd $HOME;
git clone git://github.com/ansible/ansible.git --recursive
cd ./ansible
@juliendufresne
juliendufresne / rebase.sh
Created May 15, 2016 16:05
Rebase GIT_SEQUENCE_EDITOR script
#!/bin/bash
#
# Usage:
# GIT_SEQUENCE_EDITOR='/path/to/this/script.sh' git rebase -i [options] [--exec <cmd>] [--onto <newbase>] [<upstream> [<branch>]]
#
# Description:
# This script is used as a GIT_SEQUENCE_EDITOR for the git rebase command
# It merge every commit into one single commit
# The first commit message is left as is
@juliendufresne
juliendufresne / analyze.sh
Created April 16, 2016 22:26
Remove large files and directories from git history
#!/bin/bash
# First we need to find the big files
# source: https://stackoverflow.com/questions/10622179/how-to-find-identify-large-files-commits-in-git-history/20460121#20460121
REPO_URL="git@domain.tld:your-repo-here.git"
WORKING_DIR=$(mktemp -d);
cd "${WORKING_DIR}"
git clone --mirror "${REPO_URL}" source.git;
@juliendufresne
juliendufresne / config_dev.yml
Created April 5, 2016 19:50
config for Monolog for Symfony2/Symfony3
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
console:
type: console
bubble: false