Skip to content

Instantly share code, notes, and snippets.

View AlexAtkinson's full-sized avatar

Alex Atkinson AlexAtkinson

  • Toronto
View GitHub Profile
@AlexAtkinson
AlexAtkinson / configure-aliases.sh
Last active August 12, 2022 19:41
A simple script to automatically configure some aliases for cli users.
#!/usr/bin/env bash
shell=$(awk -F/ '{print $NF}'<<<$SHELL)
# Detect target rc file.
[[ -f $HOME/.bash_profile && $shell =~ "bash" ]] && targ="$HOME/.bash_profile" # MacOS Bash
[[ -f $HOME/.zshrc && $shell =~ "zsh" ]] && targ="$HOME/.zshrc" # MacOS ZSH
[[ -f $HOME/.bashrc && $shell =~ "bash" ]] && targ="$HOME/.bashrc" # Linux
if [[ ! -n ${targ+x} ]]; then
@AlexAtkinson
AlexAtkinson / Artifacting.md
Last active March 8, 2024 16:02
A quick DevOps primer on archive artifacting for the SDLC.

Artifacting

RELATED: Versioning.md

This primer on artifacting demonstrates how to package files as zip and tar.gz, leverage a .artifactignore file similar to .gitignore, and generate and use a checksum file.

Artifacting is the process of packaging a project for distribution and/or release, and is essential to the SDLC as it mitigates many risks in both producing and consuming software products. Aside from archives, there are binaries and other language specific formats and frameworks that have their own packaging methods, but they are outside of the scope of this document. If you're interested, the serverless packaging mechanism is a good demonstration of some of the same concpets discussed here.

Generally artifacts should conform to a standard naming scheme such as: '\_.'.

@AlexAtkinson
AlexAtkinson / jenkinsfile_dynamic_user_input.groovy
Created August 25, 2022 20:38
Jenkinsfile Groovy snippet for populating a user input with docker image tags (ECR).
#!/usr/bin/env groovy
# Requires the following envars:
# - SRC_ENV : The source env/awscli profile for of the ecr repo to pull from.
# - ECR_REPO : The name of the ecr repository to pull from.
# - AWS_REGION : The AWS Region of the source repo
# This assuems the jenkins host is setup with aws profiles.
def getOptions() {
return (["/bin/bash", "-c", "aws --profile ${SRC_ENV} --region ${AWS_REGION} ecr describe-images --repository-name ${env.ECR_REPO} --query 'reverse(sort_by(imageDetails,& imagePushedAt))[0:24].imageTags' --output text | sed 's/[[:blank:]]/\\n/g' | sed '/latest/d; /SNAPSHOT/d' | sed ':a;N;\$!ba;s/\\n/ /g; s/\\s\$/\\n/g'"].execute().text.tokenize())
}
@AlexAtkinson
AlexAtkinson / constructed-secrets.yml
Last active August 26, 2022 19:01
GH Actions Constructed Secret Name Handling (Useful for handling multiple-envs scenarios)
name: Constructed Secrets
on:
workflow_dispatch:
inputs:
string:
description: "String"
required: true
secret:
description: "Secret"
@AlexAtkinson
AlexAtkinson / os-info.sh
Created August 29, 2022 15:23
BASH: OS Info helper. Reads 'os-release' options passed by user.
function os-info () {
keys=$@
function help () {
echo -e "Try: NAME, PRETTY_NAME, VERSION_ID, VERSION, ID_LIKE"
echo -e "REF: https://www.freedesktop.org/software/systemd/man/os-release.html"
return 0
}
[[ $keys == '-h' ]] && help
[[ $# -eq 0 ]] && help
for key in "$@"; do
@AlexAtkinson
AlexAtkinson / jetbrains-toolbox.desktop
Created September 1, 2022 23:27
[Linux] JetBrains ToolBox Desktop Shortcut
[Desktop Entry]
Icon=/home/foouser/.local/share/JetBrains/Toolbox/toolbox.svg
Exec=/home/foouser/.local/share/JetBrains/Toolbox/bin/jetbrains-toolbox %u
Version=1.0
Type=Application
Categories=Development
Name=JetBrains Toolbox
StartupWMClass=jetbrains-toolbox
Terminal=false
MimeType=x-scheme-handler/jetbrains;
@AlexAtkinson
AlexAtkinson / nist-randomness-beacon-eg.sh
Last active October 11, 2022 20:21
NIST Randomness Beacon Example
#!/usr/bin/env bash
# nist-randomness-beacon-eg.sh
# --------------------------------------------------------------------------------
#
# Output:
# Datetime: 2022-10-06T11:58:07
# Previous: 29B7969259B18...
# Current: 97B0CAC685FD4...
#
# Resources:
@AlexAtkinson
AlexAtkinson / variables.tf
Last active December 24, 2023 12:16
Terraform Variables - Ensure default values are changed, plus some other validations
# A collection of variable validation examples for Terraform.
#
# Test with:
# tf plan -var="environment=Development" -var="aws_region=us-east-2" -var="rds_password=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzAZaz98><" -var="subnet_public_a=10.222.16.0/20" -var="subnet_database_a=10.10.10.0/28" -var="application=testing" -var="orchestration=linktourl" -var="department=department_foo" -var="company=coolcorp"
variable "company" {
description = "The name of the company."
type = string
nullable = false
default = "CHANGEME"
@AlexAtkinson
AlexAtkinson / .bashrc
Last active June 6, 2024 23:19
BASH Aliases
# .bashrc QoL adds.
# Ultra lazy...
alias urc='source ~/.bashrc'
# Save history immediately
shopt -s histappend
#PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
# https://askubuntu.com/questions/67283/is-it-possible-to-make-writing-to-bash-history-immediate
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
@AlexAtkinson
AlexAtkinson / advanced_markdown.md
Last active March 11, 2024 14:48
Advanced Markdown Usage Cheatsheet

Advanced Markdown Usage Cheatsheet

Github Flavoured Markdown

Github markdown is not strictly markdown (though, what is...?), and is referred to as Github Flavoured Markdown, making previewing .md files necessary to ensure you're getting what you intend.

Use the GitHub Markdown Preview extension.

Examples