Skip to content

Instantly share code, notes, and snippets.

@caracolmzd
caracolmzd / find-styles.awk
Created December 29, 2024 20:52
Count occurences of CSS class names
# this script counts the occurrences of different class names in input lines
# where classes are specified using the HTML class attribute.
# It then prints the top 10 most frequently occurring class names and their counts.
BEGIN {
FS=" class="
}
@caracolmzd
caracolmzd / gen-replace-classes.awk
Created December 29, 2024 20:52
Awk TailwindCSS Util... I forget why I needed this.
#!/usr/bin/awk -f
## Awk script to convert @apply directives in a CSS file to a list of sed commands
BEGIN { RS = "}\n" }
/@apply/ {
# Extract the @apply directive name to the left of the left-curly-brace
class_name = substr($0, index($0, ".") + 1, index($0, "{") - index($0, ".") - 1);
# trim whitespace from ends
gsub(/^[ \t\n]+|[ \t\n]+$/, "", class_name);
@caracolmzd
caracolmzd / publish-image-on-tag.yml
Created June 28, 2024 17:05
DockerHub Publish Branch on new Tag
name: Publish Docker Image
on:
push:
tags:
- v*
jobs:
publish:
runs-on: ubuntu-latest
@caracolmzd
caracolmzd / safe-unlink-file.mk
Created May 23, 2022 14:37
Gnu Make Safe rm File
@caracolmzd
caracolmzd / decomposer.mk
Last active December 14, 2021 15:58
Makefile to wrap docker-compose commands
-include service/${TASK}.conf
ifdef STACK
STACK := $(strip ${STACK})
STACK_NAME := $(shell echo "${STACK}" | tr A-Z a-z)
STACK_ID := $(shell echo "${STACK}" | tr a-z A-Z)
include stack/${STACK_NAME}.conf
endif
ifdef ${STACK_ID}_STACK
@caracolmzd
caracolmzd / helper.sh
Last active August 16, 2021 17:56
SSH Proxy Tunnel Example
# bring up the ssh tunnel without requiring leaving a terminal open
# by opening a connection without a shell with the -N option.
# nohup helps to keep open the connection.
# provide an optional log, which might help troubleshooting.
# combine stderr and stdout( 2>&1 )
# send to background ( & )
connect() {
nohup ssh tunnel -N > ~/.tunnel.log 2>&1 &
}
@caracolmzd
caracolmzd / split-diffs.awk
Last active March 4, 2021 20:53
Compare two directories and generate separate patch files and a list of unique files.
BEGIN {
patch_file = "ERR" # initialize
patches = "patches" # dir to output patches
if (ENVIRON["PATCH_DIR"]) {
patches = ENVIRON["PATCH_DIR"]
}
system("test -d " patches " || mkdir -p " patches)
}
@caracolmzd
caracolmzd / mv-tags.awk
Created February 9, 2021 20:11
Rename tags matching a pattern
# # #
#
# CHANGE RELEASE TAG SCHEME
#
# re-name tags to remove the civicrm release version
# set env DEBUG=1 to preview the changes
#
# USAGE
#
@caracolmzd
caracolmzd / Makefile
Last active March 13, 2020 20:55
Makefile to on-board WP Engine sites for administration: set admin email and upgrade plugins, etc...
# # #
# Looks for ${PROJ_ROOT}conf/ssh_config.
# Export PROJ_ROOT or SSH_CONFIG
#
# Minimal orchestration through filtering of HOST_LIST
# by a prefix/suffix in ssh Host aliases specified in ENV.
# Defaults to 'stage'
#
# Targets with 'all-' prefix execute commands against all
@caracolmzd
caracolmzd / alias_gitsubs.sh
Created November 12, 2019 23:56
bash function (such as you might put in .bash_aliases) to perform git commands on nested repos
#!/bin/bash
gitsubs() {
gitsubs_max_depth=12
echo searching for git repos
echo directory max-depth = $gitsubs_max_depth
echo executing git $@
( # use a subshell and change the field-separator
# to allow for spaces in filenames