Skip to content

Instantly share code, notes, and snippets.

View dsmrt's full-sized avatar
🤙
❤️

Damien Smrt dsmrt

🤙
❤️
View GitHub Profile
@dsmrt
dsmrt / README.md
Created February 23, 2016 18:08 — forked from zenorocha/README.md
A template for Github READMEs (Markdown) + Sublime Snippet

Project Name

TODO: Write a project description

Installation

TODO: Describe the installation process

Usage

@dsmrt
dsmrt / auth.conf
Last active July 25, 2016 16:46
Whitelist a IP using htauth (apahce 2.4) when it's behind a Elastic Load Balancer
<Directory "/var/www/html/public/">
DirectoryIndex index.php index.html index.htm
ErrorDocument 404 index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
AuthType Basic
AuthName "My Protected Area"
AuthUserFile /path/to/authfile/.htpasswd
SetEnvIF X-Forwarded-For "0.0.0.0" AllowIP #change 0.0.0.0 to your whitelisted ip
<RequireAny>
@dsmrt
dsmrt / ElasticBeanstalkGetEnvironmentName.php
Last active August 4, 2016 04:58
I was surprised to see how it is to get the ElasticBeanstalk (EB) environment name from the EB instance. I wrote this quickly to fetch the name so I can run a switch on that, and have different configurations on different environments running crons.
<?php
$instanceId = file_get_contents('http://169.254.169.254/latest/meta-data/instance-id');
//I'd prefer to use the SDK here
exec('aws ec2 describe-instances --filters "Name=instance-id,Values='.$instanceId.'"',$results);
$instances = json_decode(implode(PHP_EOL,$results),true);
//fingers crossed
$tags = $instances['Reservations'][0]['Instances'][0]['Tags'];
@dsmrt
dsmrt / docker-compose.yml
Last active February 8, 2018 17:18
Flipbox Docker LAMP for CraftCMS Dev
version: "3"
services:
web:
image: flipbox/php:71-amazonlinux-apache
ports:
- 80:80
#I have a self signed cert for local dev work
- 443:443
volumes:
- .:/var/www/html
@dsmrt
dsmrt / docker-compose.yml
Created February 8, 2018 17:33
Flipbox NGINX/PHP 7.2 FPM CraftCMS docker-compose.yml
# REPOs
# https://hub.docker.com/r/flipbox/php/
version: "3"
services:
web:
image: flipbox/php:72-fpm-alpine
volumes:
- .:/app/
# point to your fpm inis
- ./general.ini:/usr/local/etc/php/conf.d/general.ini
#waiting for craftcms v3!
while true; do composer update; done
@dsmrt
dsmrt / install-saml-sp.sh
Last active April 11, 2018 16:33
Composer require Saml SP
composer require flipboxfactory/saml-sp
@dsmrt
dsmrt / alter-table-ignore-dupes.sql
Created July 12, 2018 17:13
Mysql - Remove duplicates by adding a unique key.
-- Reference: https://stackoverflow.com/questions/36647058/removing-duplicates-with-unique-index
ALTER IGNORE TABLE mytable ADD UNIQUE INDEX myindex (A, B, C, D);
@dsmrt
dsmrt / get-all-recomend-ecs-amis.bash
Created August 2, 2018 15:52
Get the latest recommended ECS optimized AMIs printed for CloudFormation Mappings
#!/bin/bash
echo "AWSRegionToAMI:"
for region in $(aws ec2 describe-regions --query 'Regions[].RegionName' --output text)
do
echo " ${region}:";
AMI=$(aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux/recommended --region $region | jq -r '.Parameters[0].Value | fromjson | .image_id')
printf " AMI: %s \n" $AMI
done
@dsmrt
dsmrt / grep-craft-log.bash
Last active February 8, 2019 18:57
Grep large craft logs. Looking for errors.
#!/bin/bash
grep -B 3 -A 10 -n '\[error\]' storage/logs/web.log