Skip to content

Instantly share code, notes, and snippets.

View etiennemarais's full-sized avatar
🇿🇦
...

Etienne Marais etiennemarais

🇿🇦
...
View GitHub Profile
@etiennemarais
etiennemarais / test.txt
Created January 8, 2015 10:40
Proposed Architecture
// App / app HTTP | commands | console | events
/ Http
/ Commands
/ Messages
/ MessageNewHttpCommand.php
/ Events
/ Messages
/ MessageWasCreatedEvent.php
@etiennemarais
etiennemarais / PackerPolicy.json
Last active March 1, 2016 14:25 — forked from MattSurabian/PackerPolicy.json
Minimum IAM policy required by AWS for Packer to do its thing.https://github.com/mitchellh/packer Permissions are broken out by API functionality and a resource array has been defined with a wild card for each group. For tighter security resource level permissions can be applied per this documentation: http://aws.typepad.com/aws/2013/07/resource…
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PackerSecurityGroupAccess",
"Action": [
"ec2:CreateSecurityGroup",
"ec2:DeleteSecurityGroup",
"ec2:DescribeSecurityGroups",
"ec2:AuthorizeSecurityGroupIngress",
@etiennemarais
etiennemarais / helpers.php
Created March 14, 2016 12:09 — forked from mabasic/helpers.php
config_path function for Lumen framework
<?php
if ( ! function_exists('config_path'))
{
/**
* Get the configuration path.
*
* @param string $path
* @return string
*/
@etiennemarais
etiennemarais / example.php
Last active April 11, 2016 14:03
Recursive match for array keys based of checking through a array of variables in a mustache template with it's includes
<?php
class ArrUtils
{
/**
* @param $searchKey
* @param $dataArray
* @return boolean
*/
protected function isKeyInArray($searchKey, $dataArray)
{
@etiennemarais
etiennemarais / templateExample.php
Created April 11, 2016 14:06
Gets all the variables from a .mustache template file with it's nested includes variables.
<?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 April 11, 2016 14:12
Collapses a multidimensional array into a simpler array that has the key as the nested dot notation along with it's value.
<?php
/**
* Link to original answer http://stackoverflow.com/a/10424516/461712 by http://stackoverflow.com/users/249538/goat
*/
class ArrUtils {
/**
* @param $array
* @return array
{
"status": 200,
"data": {
"km_per_liter": 10.79,
"liters_per_hundred_km": 9.27,
"total_trip_km": 355
}
}
@etiennemarais
etiennemarais / example.php
Last active October 27, 2016 12:16
Gets the rows from a csv file in laravel
<?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);
@etiennemarais
etiennemarais / adding better timeout for composer
Last active September 27, 2017 11:09
Notes about advanced composer
COMPOSER_TIMEOUT=600 php -d memory_limit=2G path/to/composer.phar $@
@etiennemarais
etiennemarais / gist.sh
Last active October 26, 2017 10:33
Compressing a big folder and wanting progress
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 :(