Skip to content

Instantly share code, notes, and snippets.

View dbowling's full-sized avatar
🌱
Always learning.

Dan Bowling dbowling

🌱
Always learning.
View GitHub Profile
@dbowling
dbowling / trim.zhs
Created January 28, 2025 21:53
Add this to your `.zshrc` file to give you access to `ltrim` and `rtrim`.
# usage: cat [file] | rtrim | ltrim | sort | uniq
# Right trim: Removes trailing whitespace
rtrim() {
while IFS= read -r line; do
echo "${line%"${line##*[![:space:]]}"}"
done
}
# Left trim: Removes leading whitespace
@dbowling
dbowling / lint-changed-action.yml
Created October 31, 2024 15:13
Example from markdownlint-cli-action of linting only changed files.
# source: https://github.com/DavidAnson/markdownlint-cli2-action/blob/main/.github/workflows/changed.yml
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
@dbowling
dbowling / rtg.sh
Created October 4, 2024 16:14
Run 'Til Good
#!/bin/bash
# rtg ("Run 'Til Good")
#
# Usage: ./rtg [SLEEP_SECONDS] COMMAND
#
# Runs the specified COMMAND in a loop until it successfully exits
# (i.e., returns exit code 0). Waits SLEEP_SECONDS between attempts to
# run the COMMAND. If SLEEP_SECONDS is not provided, defaults to 60 seconds.
@dbowling
dbowling / decode-jwt.sh
Last active June 26, 2024 18:15
Use jq to decode a JWT
#!/usr/bin/env bash
jq -R 'split(".") | .[1] | @base64d | fromjson' <<< "$1"
@dbowling
dbowling / merge-vars.ansible.yml
Last active June 3, 2024 15:51
How to merge variables in Ansible using the `community.general.merge_variables`.
- name: Example merge playbook
hosts: "localhost"
vars:
zabbix_agent__default__host_groups: # defined as the initial value
# will be included in the merge
- Linux
zabbix_agent__env__host_groups: # merged
- Bar
zabbix_agent__host__host_groups: # merged
curl -X PUT -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $TOKEN" https://api.github.com/notifications -d '{"last_read_at":"2023-05-07T00:00:00Z"}'
@dbowling
dbowling / only-squash-on-merge.css
Last active November 30, 2022 18:06
Refined Github Custom CSS
/*
* Disable Merge button and make Squash button the golden path
* Demo: https://share.cleanshot.com/liBQ8W
*/
.btn-group-merge {
background: #8c0000;
pointer-events: none; // disable the merge button
}
.btn-group-merge::after {
@dbowling
dbowling / Shortcuts.md
Last active July 28, 2022 23:56
Keyboard Shortcuts

VSCode

Vim / VSCodeVim

  • . repeat last command
  • z undo
  • ctrl+r redo
@dbowling
dbowling / sitemap.vm
Created March 4, 2022 17:43
Cascade velocity macro for sitemap.xml
## // TODO:
## <loc>https://www.umt.edu/academics/programs/_archive/questions/communication-studies/images/default.php</loc>
## // if not yet published
## // if last modified is greater than last published
## // create system tag to include in sitemap
## // create sitemap index https://www.sitemaps.org/protocol.html | https://moz.com/sitemaps-1-sitemap.xml
## // sitemap index can auto find all sitemaps in the domain by query tool
## // if not include in navigation, should we exclude from the sitemap?
## // changefreq value from metadata (or content type/direct path match e.g. homepage, news site)
## // priority from metadata (or content type)
@dbowling
dbowling / index.html
Created May 10, 2021 05:31 — forked from sarsamurmu/index.html
Lit CSS Plugin Snippet for Reboost JS
<html>
<head>
<script type="module" src="./build.js"></script>
</head>
<body>
<my-element></my-element>
</body>
</html>