Skip to content

Instantly share code, notes, and snippets.

View tforster's full-sized avatar
🏠
In the office

Troy Forster tforster

🏠
In the office
View GitHub Profile
@tforster
tforster / git-command-sequences.md
Last active October 19, 2024 19:38
Useful git command sequences
@tforster
tforster / branch.sh
Created February 14, 2024 23:50
Sluggified Git branch creation from GitHub/ADO ticket number and title
#!/usr/bin/env bash
#########################################################################################################################
# branch.sh is used, with arguments, to create a new branch from main that uses a slugified ADO ticket number and title #
#########################################################################################################################
# Exit immediately if a command exits with a non-zero status
set -o errexit
# Treat unset variables as an error when substituting
set -o nounset
# Fails entire pipeline if any command fails
@tforster
tforster / .zshrc
Created February 4, 2024 18:27
cw - change working directory
# A simple way of aliasing short project names to deeper working directories.
# - If you work on multiple machines and keep the same directory layout then this becomes very useful
#
# 1. Create a secret gist called joy.json that looks something like the following. Use your own meaningful project names and create as many entries as you need
#
# {
# "bookmarks": {
# "project1": "/full/path/to/the/project1/directory",
# "project2": "/full/path/to/the/project2/directory,
# }
@tforster
tforster / zsh-cli-aliases.md
Last active September 26, 2024 18:19
A collection of ZSH aliases for executing various SDK CLIs
@tforster
tforster / graphql.json
Last active February 20, 2022 20:33
Simulated GraphQL response
{
"pages": {
"/products/product-1.xml": {
"title": "Product One",
"summary": "A short summary of this product",
"detail": "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum",
"price": "$9.99",
"modelName": "product-summary"
},
"/products/product-2.xml": {
@tforster
tforster / Caddyfile
Created February 4, 2022 23:39
Caddyfile configuration for multiple Access-Control-Allow-Origin
(cors) {
@origin{args.0} header Origin {args.0}
header @origin{args.0} Access-Control-Allow-Origin "{args.0}"
}
sub.domain.com {
reverse_proxy 127.0.0.1:3000
header Access-Control-Allow-Methods *
header Access-Control-Allow-Headers content-type
header Access-Control-Allow-Credentials true
@tforster
tforster / index.js
Last active September 6, 2024 13:16
Naked Redirector CloudFront Function
/**
* @description: Handler entry point.
* - Note AWS CloudFront Functions use a modified ECMAScript 5.1 compatible runtime and NOT NodeJS.
* - Use var, not const or let
* - Use string concatenation and not template literals
* - Beware that the CloudFront Functions Console editor and test environment do NOT mimic CloudFront 100%
* @date 2022-01-26
* @param {object} event: A CloudFront Function event (expecting a Viewer Request event)
* @return {object}: A CloudFront response or request object (depends whether conditions allow pass through or 301 redirect)
*/
@tforster
tforster / MailChimp.postman_collection.json
Last active July 25, 2023 08:21
MailChimp PostMan Collection
{
"info": {
"_postman_id": "e5d286ab-6f35-46dd-a9f0-9c3c55b5db18",
"name": "MailChimp",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Get lists info",
"request": {
@tforster
tforster / .env
Created November 19, 2021 22:23
WordPress with XDebug inside Docker
# Debug state
DEBUG=true
# MySQL configuration
DB_USER=
DB_PASSWORD=
DB_NAME=
DB_HOST=db:3306
# WordPress configuration
@tforster
tforster / README.md
Last active February 26, 2021 18:39
Lambda@Edge function to implement basic auth

Basic Auth Lambda@Edge Function

Implements a simple basic auth function to attach to an AWS CloudFront distribution. Note that basic auth is inherently insecure and should not be used to protect content of value. It does work well to keep search engines and crawlers out of stage websites.

Usage

  1. Create a new Lambda function in us-east-1 (AWS does not support @Edge functions from other regions at this time.)
  2. Copy the contents of index.js to the new Lambda
  3. Replace {your-shared-username} and {your-shared-password} with actual values
  4. Attach to CloudFront as a viewer request function