Skip to content

Instantly share code, notes, and snippets.

Avatar
🇿🇦
...

Etienne Marais etiennemarais

🇿🇦
...
View GitHub Profile
@etiennemarais
etiennemarais / test.txt
Created Jan 8, 2015
Proposed Architecture
View test.txt
// App / app HTTP | commands | console | events
/ Http
/ Commands
/ Messages
/ MessageNewHttpCommand.php
/ Events
/ Messages
/ MessageWasCreatedEvent.php
@etiennemarais
etiennemarais / PackerPolicy.json
Last active Mar 1, 2016 — 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…
View PackerPolicy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PackerSecurityGroupAccess",
"Action": [
"ec2:CreateSecurityGroup",
"ec2:DeleteSecurityGroup",
"ec2:DescribeSecurityGroups",
"ec2:AuthorizeSecurityGroupIngress",
@etiennemarais
etiennemarais / helpers.php
Created Mar 14, 2016 — forked from mabasic/helpers.php
config_path function for Lumen framework
View helpers.php
<?php
if ( ! function_exists('config_path'))
{
/**
* Get the configuration path.
*
* @param string $path
* @return string
*/
@etiennemarais
etiennemarais / regex.md
Created Apr 11, 2016
Regular expression for handlebars variables, includes, if/else blocks and unescaped variables
View regex.md

Regex

{{[{]?(.*?)[}]?}}

Captures the value of the variable name in a handlebars template

{{> components/templates/email/includes/email-tr-spacer }}
{{# deliveryAddress }}
@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)
{
@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
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
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 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);
@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