Skip to content

Instantly share code, notes, and snippets.

View djteej's full-sized avatar

Trevor Smith djteej

View GitHub Profile
@djteej
djteej / setup.sh
Created June 14, 2017 20:43
a user-data file to setup Docker and Docker Compose on an AWS EC2 instance running Ubuntu
#!/usr/bin/env bash
# config
UBUNTU_VERSION=$(lsb_release -cs)
DOCKER_COMPOSE_VERSION="1.13.0"
# update and install some required packages
apt-get update && apt-get upgrade -y && apt-get install -y apt-transport-https ca-certificates curl software-properties-common
# add Docker's official GPG key
@djteej
djteej / wp-backup-s3.sh
Created March 16, 2017 20:39
A simple shell script to backup a WordPress website and database to an AWS S3 bucket then publish the results to a Slack channel
#!/bin/bash
# config
dbhost='********'
dbuser='********'
dbpass='********'
dbname='********'
webroot='/var/www/html'
s3bucket='********'
webhook='https://hooks.slack.com/services/*********/*********/************************'
@djteej
djteej / apt-check-notify-slack.sh
Last active March 16, 2017 20:12
A simple shell script to check APT for updatable packages then publish the results to a Slack channel
#!/bin/bash
# post message to Slack (see: https://api.slack.com/incoming-webhooks)
slack () {
webhook='https://hooks.slack.com/services/*********/*********/************************'
if [ -z "${1}" ]; then
code=0
fi
curl -X POST --data-urlencode "payload={\"text\": \"\`\`\`${message}\`\`\`\"}" "${webhook}"
exit ${code}
@djteej
djteej / Example NGINX Server Block to rewrite all domains to a single valid domain
Created March 27, 2015 13:56
An example of a *proper* NGINX Server Block to rewrite all domains to a single valid domain
# Example NGINX Server Block to rewrite all domains to a single valid domain
#
# Note: Requires an additional NGINX Server Block for the valid domain
#
# Author: Trevor Smith <djtrevorsmith@gmail.com>
# http://teej.ca
#
# Software: PHP 5.5.9
# NGINX 1.4.6
# Phalcon 1.3.4
@djteej
djteej / Example NGINX PHP Phalcon Server Block
Created March 27, 2015 13:49
An example of a *proper* NGINX Server block for passing PHP requests to a Phalcon application
# Example NGINX PHP Phalcon Server Block
#
# Author: Trevor Smith <djtrevorsmith@gmail.com>
# http://teej.ca
#
# Software: PHP 5.5.9
# NGINX 1.4.6
# Phalcon 1.3.4
server {
listen 80;
@djteej
djteej / ShareCount.php
Created July 30, 2013 20:19
A simple PHP class for retrieving the total share counts of various social networking services for a given URL. Currently includes: Facebook, Twitter, LinkedIn and Google+
<?php
/**
* ShareCount
*
* Retrieves the total share counts of various social networking services for a given URL.
* Currently includes: Facebook, Twitter, LinkedIn and Google+
*
* @author Trevor Smith <djtrevorsmith@gmail.com>
* @copyright 2013 Trevor Smith (http://teej.ca)
* @license http://www.opensource.org/licenses/mit-license.php MIT