Skip to content

Instantly share code, notes, and snippets.

Avatar
🇿🇦
...

Etienne Marais etiennemarais

🇿🇦
...
View GitHub Profile
View Alias.git
[alias]
# Git Commit, Add all and Push — in one step.
cap = "!f() { git add .; git commit -m \"$@\"; }; f"
# NEW.
new = "!f() { git cap \"📦 NEW: $@\"; }; f"
# IMPROVE.
imp = "!f() { git cap \"👌 IMPROVE: $@\"; }; f"
# FIX.
fix = "!f() { git cap \"🐛 FIX: $@\"; }; f"
@etiennemarais
etiennemarais / logslaravel.sh
Last active Sep 17, 2018 — forked from jakebathman/logslaravel.sh
Tail Laravel logs and filter out the stack traces
View logslaravel.sh
tail -f -n 450 laravel*.log \
| grep -i -E \
"^\[\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\]|Next [\w\W]+?\:" \
--color
@etiennemarais
etiennemarais / gist.sh
Last active Oct 26, 2017
Compressing a big folder and wanting progress
View gist.sh
sudo su
tar cf - <folder> -P | pv -s $(du -sb <folder> | awk '{print $1}') | gzip > data.tar.gz
# Outputs something like this
# 3.06GiB 0:03:01 [15.8MiB/s] [========> ] 5% ETA 0:57:05
#
# I recently needed to perform a data recovery on a bad migration where I deleted the wrong stuff. I tried to recover data
# from a mysql 5.5 dump to a mysql 5.7 ubuntu 16.04 google cloud box and even though I could edit the data and fix the deleted
# rows in the tables, I coulnd't export it well enough since incompatibilities between 5.5 and 5.7 :(
View adding better timeout for composer
COMPOSER_TIMEOUT=600 php -d memory_limit=2G path/to/composer.phar $@
@etiennemarais
etiennemarais / .zshrc
Last active Jul 18, 2018
Quick alias to remove and clean untagged docker images and stopped containers.
View .zshrc
#
# Credit to http://jimhoskins.com/2013/07/27/remove-untagged-docker-images.html
#
# Add this to your bash profile.
#
clean_docker () {
# Remove stopped containers
docker rm $(docker ps -a -q);
# Remove untagged images
@etiennemarais
etiennemarais / example.php
Last active Oct 27, 2016
Gets the rows from a csv file in laravel
View example.php
<?php
/*
* Gets the rows from a csv file in laravel. via https://github.com/johnmarkmassey :+1:
*/
$rows = array_map('str_getcsv', file(app_path('database/migrations/test_data.csv')));
var_dump($rows);
View testData.json
{
"status": 200,
"data": {
"km_per_liter": 10.79,
"liters_per_hundred_km": 9.27,
"total_trip_km": 355
}
}
@etiennemarais
etiennemarais / example.php
Last active Apr 11, 2016
Collapses a multidimensional array into a simpler array that has the key as the nested dot notation along with it's value.
View example.php
<?php
/**
* Link to original answer http://stackoverflow.com/a/10424516/461712 by http://stackoverflow.com/users/249538/goat
*/
class ArrUtils {
/**
* @param $array
* @return array
@etiennemarais
etiennemarais / templateExample.php
Created Apr 11, 2016
Gets all the variables from a .mustache template file with it's nested includes variables.
View templateExample.php
<?php
class Helper
{
/**
* Finds all mustache template tokens ex:
* {{> components/templates/email/includes/email-tr-spacer-thin }}
* {{# deliveryAddress }}
* {{^ deliveryAddress }}
* {{{ deliveryAddressReadable }}}
* {{ deliveryAddressReadable }}
@etiennemarais
etiennemarais / example.php
Last active Apr 11, 2016
Recursive match for array keys based of checking through a array of variables in a mustache template with it's includes
View example.php
<?php
class ArrUtils
{
/**
* @param $searchKey
* @param $dataArray
* @return boolean
*/
protected function isKeyInArray($searchKey, $dataArray)
{