Skip to content

Instantly share code, notes, and snippets.

View laurentsab's full-sized avatar

Laurent Sabatier laurentsab

View GitHub Profile
@laurentsab
laurentsab / gist:878005568c4501a90d55
Created October 9, 2015 09:34
update a GitHub forked repository
# http://stackoverflow.com/questions/7244321/how-to-update-a-github-forked-repository
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream
# Make sure that you're on your master branch:
@laurentsab
laurentsab / twig_loopModulo.html.twig
Created November 27, 2015 14:27
Twig Loop modulo
<div class="row">
<div class="col-md-9">
<div class="row">
{% if children is defined and children.pager.currentPageResults|length %}
{% for child in children.pager.currentPageResults %}
{% if loop.index0 % 2 == 0 and not loop.first %}
</div>
<div class="row">
{% endif %}
@laurentsab
laurentsab / twig_merge_attributes
Created January 20, 2016 09:02
Twig merge attributes
// parent_template.html.twig
{% include "AppBundle:fields:input_text.html.twig" with {
'form_id': form_id,
'field_name': 'Numéro',
'required': true,
'attr': {
'data-minlength': '\\d{7}',
'minlength': '7',
'maxlength': '7',
'data-error': 'e0.message_error'|trans()
@laurentsab
laurentsab / Docker Tips
Created April 8, 2016 07:30
Docker Tips
// allow history for root user on container
// on /root/.bashrc
// add:
HISTFILE="/root/.bash_history"
@laurentsab
laurentsab / ngrok
Created August 18, 2016 14:18
ngrok How to
$ ./ngrok http -region eu -host-header=rewrite {LocalSiteName}.local:80
// On browser or mobile browser, share page like:
http://bae8d36b.eu.ngrok.io
@laurentsab
laurentsab / foreach.php
Last active June 9, 2017 07:41
Manipulate keys values in foreach
<?php
/**
* @param array $array
*
* @return array
*/
protected function translate($array)
{
$filtersChoicesTrans = [];
foreach ($array as $key => $value) {