Skip to content

Instantly share code, notes, and snippets.

View particledecay's full-sized avatar
💣
0 17 * * 5 /usr/local/bin/deploy_to_prod.sh

Joey Espinosa particledecay

💣
0 17 * * 5 /usr/local/bin/deploy_to_prod.sh
View GitHub Profile
#!/usr/bin/env python
import json
import yaml
def yaml_to_json(data):
yaml_data = yaml.safe_load(data)
json_data = json.dumps(yaml_data)
return json_data
@particledecay
particledecay / .gitconfig
Created July 6, 2020 18:49
My preferred Git(Hub) config
[alias]
co = checkout
ci = commit -S
st = status -s
br = branch
sui = submodule update --init
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(b old yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
branch-name = rev-parse --abbrev-ref HEAD
upstream-name = !git remote | egrep -o '(upstream|origin)' | tail -1
@particledecay
particledecay / gist:7e4bfad1236856a194139bce3655b755
Last active May 14, 2020 22:58
Generate a changelog/release notes using Conventional Commit standards
# one-liner
if [ -z "$(git tag -l --sort=v:refname | tail -1)" ]; then git log --oneline --all; else git log --oneline $(git tag -l --sort=v:refname | tail -1)..$(git rev-parse --abbrev-ref HEAD); fi | awk '$2 ~ /:/' | sort -sk 2,2 | awk 'BEGIN {print "## Changelog"} NR == 1 {print "- " $0; type = gensub(/(\w+).*:/, "\\1", 1, $2)} NR > 1 && $2 !~ type {print ""} NR > 1 {print "- " $0; type = gensub(/(\w+).*:/, "\\1", 1, $2)}'
# nicely formatted
if [ -z "$(git tag -l --sort=v:refname | tail -1)" ]
then
git log --oneline --all
else
git log --oneline $(git tag -l --sort=v:refname | tail -1)..$(git rev-parse --abbrev-ref HEAD)
fi | awk '$2 ~ /:/' \
@particledecay
particledecay / docker_cleanup
Created January 16, 2020 16:25
Clean up a system with docker on it regardless of version
[[ "$(echo "$(docker version -f '{{.Server.APIVersion}}')\n1.25" | sort -V | head -1)" == "1.25" ]] && (docker system df && docker system prune -a --volumes) || (docker rmi $(docker images --filter "dangling=true" -q --no-trunc) && docker volume rm $(docker volume ls -qf dangling=true) && docker rm $(docker ps -qa --no-trunc --filter "status=exited"))
@particledecay
particledecay / ssh_target_group.sh
Created August 28, 2019 20:48
SSH to all instances within an AWS target group
#!/bin/bash
ssh_user=joey.espinosa
aws_region=us-west-1
export target_group=$1
# grab AWS info
target_arn=$(aws elbv2 describe-target-groups --region ${aws_region} --query "TargetGroups[?TargetGroupName==\`${target_group}\`].TargetGroupArn" --output text)
instance_ids=$(aws elbv2 describe-target-health --target-group-arn $target_arn --region ${aws_region} --query "TargetHealthDescriptions[*].Target.Id" --output text)
ip_addresses=( $(aws ec2 describe-instances --region ${aws_region} --instance-ids $instance_ids --query "Reservations[*].Instances[*].PrivateIpAddress" --output text ) )
@particledecay
particledecay / popup_alert
Created January 24, 2019 06:27
Queue a popup alert at some point in the future
#!/bin/bash
echo -n "Time to alert: " && read TIME
echo -n "Alert message: " && read MESSAGE
#echo "zenity --info --text '${MESSAGE}'" | at $TIME
at $TIME <<EOF
export DISPLAY=:0.0
zenity --info --text "${MESSAGE}"
EOF
{
"window.titleBarStyle": "native",
"editor.fontFamily": "Dank Mono",
"editor.fontLigatures": true,
"workbench.startupEditor": "none",
"workbench.colorTheme": "Bluloco Dark Italic",
"editor.minimap.enabled": false,
"go.inferGopath": true,
"[yaml]": {
"editor.detectIndentation": false,
@particledecay
particledecay / commit-msg
Created October 12, 2018 14:32
Git hook for enforcing Conform commit message policies
#!/bin/sh [0/68765]
#
# A hook script to check for conventional commit message format.
# only run if a config exists
if [ ! -f ./.conform.yaml ]
then
echo "No .conform.yaml file found. Ignoring conform."
exit 0
fi
def chop(sliceable, columns):
"""Return multiple selected slices of an iterable, in desired order.
Args:
sliceable (list): the original list to chop up
columns (list): a list of integers (indices) or tuples (slices)
Returns:
(list) the final chopped up list
@particledecay
particledecay / go.py
Last active May 5, 2016 14:33
Very simple (and incomplete) implementation of Go in Python
import sys
import unittest
from StringIO import StringIO
EMPTY = 0
BLACK = 1
WHITE = 2
class Board:
def __init__(self):