Skip to content

Instantly share code, notes, and snippets.

View nicksantamaria's full-sized avatar

Nick Santamaria nicksantamaria

View GitHub Profile
@nicksantamaria
nicksantamaria / config.yml
Created July 9, 2020 01:26
Terraform CircleCI Workflow
version: 2
jobs:
plan:
docker:
- image: hashicorp/terraform:latest
working_directory: /code
steps:
- checkout
- run:
name: Init
@nicksantamaria
nicksantamaria / cmd.sh
Created May 19, 2020 23:48
copy lagoon-as-a-service JWT to clipboard
cat ~/.lagoon.yml | grep -a5 'amazeeio:' | grep token | awk -F': ' '{print $2}' | pbcopy
function dc() {
FILES=""
if [ -f docker-compose.yml ]; then
FILES+="-f docker-compose.yml "
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
if [ -f docker-compose.osx.yml ]; then
FILES+="-f docker-compose.osx.yml "
fi
if [ -f docker-compose.catalina.yml ]; then
@nicksantamaria
nicksantamaria / prime.sh
Created September 13, 2019 05:57
Prime images from homepage
# Prime the caches and stage file proxy by requesting the homepage and image resources.
DOMAIN=''
HTTP_USER=''
HTTP_USER=''
wget \
--recursive --delete-after -nd --level=0 \
--read-timeout=5 --waitretry=5 --timeout=5 -t 3 \
-A png -A jpg -A jpeg \
--user=${HTTP_USER} --password=${HTTP_USER} --keep-session-cookies https://${DOMAIN}/
@nicksantamaria
nicksantamaria / readme.md
Created August 16, 2019 06:27
Backup and Restore with skpr/operator

Backup and Restore with skpr/operator

In github.com/skpr/operator are CRDs which you can use to handle backups and restores of applications with state stored in mysql and persistent volume claims.

The three CRDs are:

  • Backup - Takes a list of PVCs and databases to backup, and stores them in a restic repository.
  • BackupScheduled - Essentially a cronjob template for Backup, but with a cron expression to define the frequency.
  • Restore - Takes a backup ID, and destination PVCs and mysql databases to restore to.
@nicksantamaria
nicksantamaria / run.sh
Last active February 26, 2021 01:12
Boilerplate bash script
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
#/ Usage:
#/ Description:
#/ Examples:
#/ Options:
#/ --help: Display this help message
usage() { grep '^#/' "$0" | cut -c4- ; exit 0 ; }
@nicksantamaria
nicksantamaria / goenv.sh
Last active June 15, 2017 07:53
Script to update your GOPATH when working with multiple workspaces.
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
#/ Usage: source ./goenv.sh
#/ Description: Adjusts GOPATH environment variable to support multiple workspaces.
#/ Inspired by https://github.com/dgnorton/goenv/blob/master/goenv.sh
#/ Options:
#/ --help: Display this help message
usage() { grep '^#/' "$0" | cut -c4- ; exit 0 ; }
@nicksantamaria
nicksantamaria / aws-get-elb-cloudfront-ips.sh
Last active November 9, 2021 19:37
Retrieve a list of CIDR ranges for AWS ELBs and CloudFront (relevant to Sydney region).
# Region: Sydney (ap-southeast-2)
# Service: ELBs.
curl -ss https://ip-ranges.amazonaws.com/ip-ranges.json | jq -arM -c '.prefixes[] | select(.region | contains("ap-southeast-2")) | select(.service | contains("AMAZON")) | .ip_prefix' | tee results.txt
# Region: Sydney (ap-southeast-2)
# Service: CloudFront.
curl -ss https://ip-ranges.amazonaws.com/ip-ranges.json | jq -arM -c '.prefixes[] | select(.region | contains("ap-southeast-2")) | select(.service | contains("CLOUDFRONT")) | .ip_prefix' | tee -a results.txt
# Region: Global
# Service: CloudFront.
@nicksantamaria
nicksantamaria / pr.md.txt
Last active December 12, 2016 22:00
DevOps Pull Request Template
#### What does this PR do?
#### Where should the reviewer start?
#### How should this be manually tested?
#### Any background context you want to provide?
#### What are the relevant tickets?
@nicksantamaria
nicksantamaria / fork-example.php
Created October 20, 2016 22:35
Example: Parallel processing in PHP using pcntl_fork()
<?php
/**
* @file
* Basic demonstration of how to do parallel threads in PHP.
*/
// This array of "tasks" could be anything. For demonstration purposes
// these are just strings, but they could be a callback, class or
// include file (hell, even code-as-a-string to pass to eval()).