Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Chris Fidao fideloper

Block or report user

Report or block fideloper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fideloper
fideloper / connections.sh
Created Dec 19, 2018
Quick and dirty monitoring of mysql connections
View connections.sh
#!/usr/bin/env bash
# 5 minutes between alerts
SECONDS_BETWEEN_ALERTS=300
# Track when we sent the last alert
LAST_ALERT=0
while true; do
NUMBER_CONNECTIONS=$(mysql --defaults-extra-file=/data/.prod.cnf -sNe "select count(*) as connection_count from INFORMATION_SCHEMA.PROCESSLIST;")
@fideloper
fideloper / transactions.md
Created Mar 17, 2018
write up on transactions
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
@fideloper
fideloper / stream_file.php
Last active Apr 30, 2019
Stream file from S3 to browser, assume Laravel Filesystem usage
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';
@fideloper
fideloper / start-container.sh
Last active Dec 19, 2018
Enable/Disable xDebug depending on env.
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
@fideloper
fideloper / convert_attach_from_db_to_file.php
Last active Dec 7, 2016
Converting Database Stored Attachments to the File System
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);
@fideloper
fideloper / develop
Created Nov 24, 2016
Helper for Laravel + Docker dev workflow
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
@fideloper
fideloper / tags.py
Created Nov 4, 2016
Change many aws instances tags (boto3)
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 = []
@fideloper
fideloper / provision.sh
Created Jun 27, 2016
Provision ubuntu 16.04 vagrant machine
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
You can’t perform that action at this time.