Instantly share code, notes, and snippets.

View transactions.md

What we're demonstrating here is that it's probably smart to do most database operations in a transaction, even SELECT statements.

View tables.md
Mac Linux Windows
Install Docker on Mac Install Docker on Debian Not Currently Supported
Install Docker on Ubuntu
Install Docker on CentOS
View stream_file.php
<?php
/*************************************************************************
* Get File Information
*/
// Assuming these come from some data source in your app
$s3FileKey = 's3/key/path/to/file.ext';
$fileName = 'file.ext';
View start-container.sh
#!/usr/bin/env bash
###
# A CMD or ENTRYPOINT script for a Dockerfile to use to start a Nginx/PHP-FPM
#
# For more details, see 🐳 https://shippingdocker.com
##
if [ ! "production" == "$APP_ENV" ] && [ ! "prod" == "$APP_ENV" ]; then
# Enable xdebug
View convert_attach_from_db_to_file.php
<?php
/*
* Notes:
* This script will convert attachments from being stored on the DB to the file system
* NOTE: This script removes the atachments from your database. Before running this script make a backup. For real.
*/
//No time limit
set_time_limit(0);
View develop
#!/usr/bin/env bash
# Set environment variables for dev
export APP_ENV=local
export APP_PORT=80
export DB_PORT=3306
export DB_ROOT_PASS=secret
export DB_NAME=homestead
export DB_USER=homestead
export DB_PASS=secret
View tags.py
import boto3
import sys
ec2 = boto3.client('ec2')
# Grab where backup retention is 14 days so we can reduce it to 7
instances = ec2.describe_instances(Filters=[{'Name': 'tag:Retention', 'Values': ['14']}])
ids = []
View provision.sh
#!/usr/bin/env bash
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get -y upgrade
# Get "add-apt-repository" Command
sudo apt-get install -y software-properties-common
View 22-fluentd.conf
# rsyslog conf referenced in tasks.yml
*.* @127.0.0.1:42185