Skip to content

Instantly share code, notes, and snippets.

View bradymholt's full-sized avatar

Brady Holt bradymholt

View GitHub Profile
@bradymholt
bradymholt / playbook.yml
Last active September 22, 2016 22:09
Create Digital Ocean Droplet with Ansible
- name: Digital Ocean
hosts: all
connection: local
gather_facts: false
vars:
do_token: abc123
droplets:
- vippers-one
- vippers-two
- vippers-three
@bradymholt
bradymholt / index.ts
Last active June 20, 2017 16:51
Delete GitHub releases and tags matching a prefix pattern
/*
Example usage:
ts-node index.ts bradyholt/repo123 ~/dev/repo123 devtag
*/
import axios from "axios";
import childProcess = require("child_process");
let repoName = process.argv[2];
let repoPath = process.argv[3];
@bradymholt
bradymholt / Zbig-o.png
Last active October 22, 2021 13:16
Computer Science Concepts
Zbig-o.png
@bradymholt
bradymholt / advanced.config
Created September 1, 2018 21:08
rabbitmq-email config
[
{rabbitmq_email, [
%% gen_smtp server parameters
%% see https://github.com/Vagabond/gen_smtp#server-example
{server_config, [
[{port, 2525}, {protocol, tcp}, {domain, "geekytidbits.com"}, {address,{0,0,0,0}}]
]},
%% how clients are authenticated; either 'false' or 'rabbitmq' (default)
{server_auth, false},
%% whether STARTTLS shall be offered; either 'true' or 'false' (default)
@bradymholt
bradymholt / gist:15d210f3eee4637d3a20ca3f74d9cc6a
Created November 22, 2019 18:05
Delete Private GitHub Docker Registry packages
# Find latest version of packages
curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer $GITHUB_API_TOKEN" \
-d '{"query":"query { repository(owner:\"johndoe\", name:\"myepo\") { registryPackagesForQuery(first:10) { edges { node { latestVersion { id } } } } } }"}' \
https://api.github.com/graphql
# Example output from above command
# {"data":{"repository":{"registryPackagesForQuery":{"edges":[{"node":{"latestVersion":{"id":"MDE01234523233"}}}]}}}}
@bradymholt
bradymholt / gist:fc8ec86dbc00098ee4622e1dbe69776c
Created December 22, 2019 01:06
Create PostgreSQL user and give permissions to objects in database
SELECT set_config('current.user', 'my_user', false);
SELECT set_config('current.dbname', 'my_database', false);
CREATE USER current_setting('current.user');
-- Give CREATE, CONNECT, TEMPORARY permissions
GRANT ALL PRIVILEGES ON DATABASE current_setting('current.dbname') TO current_setting('current.user');
-- Grant INSERT, UPDATE, DELETE access to all EXISTING tables in public schema
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO current_setting('current.user');
@bradymholt
bradymholt / pollster.groovy
Created May 28, 2020 02:30
“Pollster” - A SmartThings Polling Daemon
/**
* Pollster - The SmartThings Polling Daemon.
*
* Pollster works behind the scenes and periodically calls 'poll' or
* 'refresh' commands for selected devices. Devices can be arranged into
* three polling groups with configurable polling intervals down to 1 minute.
*
* Please visit [https://github.com/statusbits/smartthings] for more
* information.
*
@bradymholt
bradymholt / delete_draft_releases.sh
Created September 2, 2020 15:22
Delete GitHub draft releases
TOKEN=123; curl -Ss -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
"https://api.github.com/repos/username/repo_name/releases?per_page=100&page=1" \
| jq -r '.[] | select(.draft == true) | .id' \
| xargs -I {} -L 1 \
curl -L -H "Authorization: token $TOKEN" -X DELETE "https://api.github.com/repos/username/repo_name/releases/{}"
git-move() {
echo "Moving commits on current branch to a new branch..."
# This is useful if commits were mistakenly made on master and need to be move to a new branch.
# $1 - New target branch name
if [ -z "$1" ]; then echo "New branch name required!"; exit 0; fi
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Moving local commits on ${CURRENT_BRANCH} to $1"
git branch ${1} && git reset --hard origin/${CURRENT_BRANCH} && git checkout ${1}
}
@bradymholt
bradymholt / delete_all_disabled_workflow_runs.sh
Created January 12, 2022 18:18
Delete all disabled GitHub Action workflow runs
# Source :https://stackoverflow.com/a/67000032/626911
org=<your org>
repo=<your repo>
# Get workflow IDs with status "disabled_manually"
workflow_ids=($(gh api repos/$org/$repo/actions/workflows | jq '.workflows[] | select(.["state"] | contains("disabled_manually")) | .id'))
for workflow_id in "${workflow_ids[@]}"
do
echo "Listing runs for the workflow ID $workflow_id"