Skip to content

Instantly share code, notes, and snippets.

@pwillis-els
pwillis-els / ABOUT_AWS_COGNITO.md
Last active January 28, 2021 01:31
A description of what AWS Cognito is and how it works
@pwillis-els
pwillis-els / add_custom_package_to_composer.md
Created January 13, 2021 02:55
Composer: Add a package repository for code that doesn't live in a repository to your composer.json

If you need to track a package with Composer but it doesn't exist in a repository, you can still manage it with Composer. Simply create a custom repository of type 'package', add it to your required packages, and proceed as normal.

  1. Open your composer.json and add a a block to the 'repositories' array like the following.
{
  "repositories": [
    {
      "type": "package",
@pwillis-els
pwillis-els / get-local-wp-plugin-vers.sh
Created January 13, 2021 01:48
Get locally installed Wordpress plugin versions
#!/bin/sh
# This will display the wordpress plugin name and version, based on some standard formatting
# in a .php file in each plugin. If the plugin author didn't use this convention, this probably
# won't work... but it works for me.
grep -e "^[ *]*Version:" wp-content/plugins/*/*.php | sed -e 's/wp-content\/plugins\/\(.\+\)\/.*\.php:[ *]*Version:[[:space:]]*\(.*\)$/\1:\2/g'
@pwillis-els
pwillis-els / make-new-bedrock-instance.sh
Created January 13, 2021 01:30
Friendly shell interface for generating a new Bedrock (WordPress) instance
#!/usr/bin/env bash
set -euo pipefail
[ "${DEBUG:-0}" = "1" ] && set -x
[ -n "${PROJECT_NAME:-}" ] || read -r -p "Project name [wordpress]: " PROJECT_NAME
[ -n "${PROJECT_NAME:-}" ] || PROJECT_NAME="wordpress"
[ -n "${WP_HOME:-}" ] || read -r -p "Website URL [https://localsite.localdomain]: " WP_HOME
[ -n "${WP_HOME:-}" ] || WP_HOME="https://localsite.localdomain"
[ -n "${WP_SITEURL:-}" ] || read -r -p "Wordpress URL [https://localsite.localdomain/wp]: " WP_SITEURL
@pwillis-els
pwillis-els / Dockerfile
Created January 7, 2021 00:37
Dockerfile for building Go applications with multi-stage builds
FROM golang:alpine as build
RUN apk add -U --no-cache git
WORKDIR /build
COPY /core /build/core
COPY /vendor /build/vendor
COPY *.mod *.sum *.go /build/
@pwillis-els
pwillis-els / Dockerfile
Created January 7, 2021 00:31
Dockerfile for building Rust applications with multi-stage builds
FROM rust as build
WORKDIR /build
COPY /src /build/src
COPY /man /build/man
COPY build.rs Cargo.toml /build/
RUN cargo build --release
@pwillis-els
pwillis-els / attach_ebs.sh
Last active December 6, 2023 07:03
Bash script to attach an EBS volume to an EC2 instance after boot-time
#!/bin/sh
# attach_ebs.sh - Attach an EBS volume to an EC2 instance.
# Copyright (C) 2020 Peter Willis <peterwwillis+github@gmail.dotcom>
#
# This script is designed to create and mount a single EBS volume based on its tag:Name
# in order to implement persistent storage. If there is more than one EBS volume
# with the same tag, this script will fail.
#
# Order of operations:
# 1. Detect EBS volume based on "tag:Name" "$TAG_NAME"
@pwillis-els
pwillis-els / use_https_instead_of_ssh_for_github_access_credentials.md
Created December 31, 2020 20:09
Why you should use HTTPS instead of SSH for GitHub credential access

About

HTTPS and Personal Access Tokens are the preferred method to use GitHub, rather than SSH keys. Here I'll explain why.

SSH key problems

Accepting Host Keys

If you access GitHub using SSH, you're required to accept the host keys of github.com the first time you pull a repo. This might not be a problem if you're using your own workstation, as the cached host keys will stick around for a long time.

@pwillis-els
pwillis-els / jenkins_cheat_sheet.md
Last active December 31, 2020 05:39
Jenkins Cheat Sheet

Plugins

What plugins are installed on my Jenkins server?

  • There are "Downloaded plugins" and there are "Bundled plugins".
    • Bundled plugins come in the jenkins.war file which contains the Jenkins Core code. You may need to check for security updates for these separate from your downloaded plugins. When you change your Jenkins Core version, you'll want to re-check these plugins.
    • Downloaded plugins must be downloaded and installed aside from the jenkins.war file.
  • Plugins can have a .jpi' or .hpi file extension.

From the filesystem

@pwillis-els
pwillis-els / jenkins-plugin-manager.sh
Last active December 29, 2020 02:04
Wrapper for Jenkins plugin-installation-manager-tool
#!/usr/bin/env sh
set -eu
[ "${DEBUG:-0}" = "1" ] && set -x # set DEBUG=1 to enable tracing
VERSION="2.5.0"
NAME="jenkins-plugin-manager-$VERSION"
URL="https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/$VERSION/$NAME.jar"
[ -n "${JENKINS_DOCKER_IMG:-}" ] || \
JENKINS_DOCKER_IMG="jenkins/jenkins"