Skip to content

Instantly share code, notes, and snippets.

View anthonyheckmann's full-sized avatar

Tony Heckmann anthonyheckmann

View GitHub Profile
#!/bin/bash
# dedupe_list() is a helper function to dedupe a list of items separated by a given separator
# eg dedupe_list ":" "a:b:a:c" will return "a:b:c", or dedupe_list ":" "$PATH" will return a deduped $PATH
# the seperator you pass is used to split the existing list, and reinserted in the same order
dedupe_list() {
local separator="$1"
# Use awk to preserve order while deduping
echo "$2" | tr "$separator" '\n' | awk '!seen[$0]++ && NF' | tr '\n' "$separator"
}
@anthonyheckmann
anthonyheckmann / font_forge_combine_fonts.sh
Created April 18, 2024 17:00
bash script with example of using font-forge to create a ttc file (or many) from a collection of .ttf and .otf files. Good for reducing the number of necessary files
#!/usr/bin/env bash
# example of using fontforge from the CLI to merge fonts into a single TTC file
# also removes extra spaces from metadata and can remove a specific string from metadata
fontforge -lang=py -c "$(cat <<EOF
from os import remove
import sys
import glob
@anthonyheckmann
anthonyheckmann / awk.nagios_cfg_to_yaml.example
Created April 5, 2024 00:35
reasonable awk script to convert Nagios .cfg files into yaml
awk -v RS='' -v FS='\n' -v OFS='\n' 'BEGIN {}
BEGINFILE {print "---"; print FILENAME ":"}
{
for (i=1; i<=NF; i++) {
gsub(/^[ \t]+|[ \t]+$/, "", )
if ( ~ /^define (command|contact|contactgroup|host|hostgroup|service|servicegroup|timeperiod)/) {
split(, a, /[ {]/)
define = 1
in_section = a[2]
@anthonyheckmann
anthonyheckmann / syncedTabsToBookmarksHTML.js
Created November 24, 2023 19:13 — forked from jscher2000/syncedTabsToBookmarksHTML.js
Export Synced Tabs List to "bookmarks.html" file (Browser Console script)
// Run code in Browser Console after enabling chrome debugging --
// about:config => devtools.chrome.enabled => true
// https://developer.mozilla.org/docs/Tools/Browser_Console
try {
var tabPromise = SyncedTabs._internal.getTabClients();
tabPromise.then((arrDevices) => {
if (arrDevices && arrDevices.length > 0){
// Generate a string with the format of a bookmark export file
var d, e, out = '<!DOCTYPE NETSCAPE-Bookmark-file-1>\n<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">\n<TITLE>Bookmarks</TITLE>\n<H1>Bookmarks Menu</H1>\n<DL><p>\n';
const escapeHtmlEntities = function(aText){return (aText || '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;')};
@anthonyheckmann
anthonyheckmann / update_git_repos.sh
Created February 15, 2022 14:50 — forked from douglas/update_git_repos.sh
Update all git repositories under a base directory
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# Let the person running the script know what's going on.
echo "\n\033[1mPulling in latest changes for all repositories...\033[0m\n"
# Find all git repositories and update it to the master latest revision
for i in $(find . -name ".git" | cut -c 3-); do
@anthonyheckmann
anthonyheckmann / README.md
Created February 26, 2020 15:06 — forked from magnetikonline/README.md
List all Git repository objects by size.

List all Git repository objects by size

Summary

Bash script to:

  • Iterate all commits made within a Git repository.
  • List every object at each commit.
@anthonyheckmann
anthonyheckmann / record_packages.sh
Last active August 22, 2019 15:57
Bash script to dump out installed packages for a number of systems
#!/usr/bin/env bash
# Script create report for installed packages
#TODO check bash version, probably need >4
DEBUG=0
function my_debug() {
local debug_prefix="DEBUG:\t"
if [ $DEBUG -gt 0 ]; then
@anthonyheckmann
anthonyheckmann / bootstrap.sh
Created August 14, 2019 14:13 — forked from drmikecrowe/bootstrap.sh
Bash Bootstrap
#!/usr/bin/env bash
APT_PKGS=""
function install {
FILE="$2"
URL="$1/$FILE"
wget $URL -O $FILE
sudo gdebi $FILE
rm $FILE
@anthonyheckmann
anthonyheckmann / track.c
Last active June 12, 2019 18:41
simple X window tracker application
/* Found here https://bbs.archlinux.org/viewtopic.php?pid=1551884#p1551884
By user Trilby
Compile with `gcc -o track track.c -lX11`, and consider putting into .xinitrc
like `track >> window.log`
*/
#include <stdio.h>
#include <time.h>
#include <X11/Xlib.h>

Keybase proof

I hereby claim:

  • I am anthonyheckmann on github.
  • I am anthonyheckmann (https://keybase.io/anthonyheckmann) on keybase.
  • I have a public key ASB6Rs5oOUHq8dGW069aR8IYhQVsX60bHUwevZ3X5posHwo

To claim this, I am signing this object: