Skip to content

Instantly share code, notes, and snippets.

@samba
samba / README.md
Last active February 24, 2026 22:22
Google Tag Manager Utility Scripts

Utility Scripts for Google Tag Manager

Each script should include some outline of its usage. In general, the scripts will require installation as a Custom HTML tag in GTM, and should be triggered to run on every page.

Custom HTML scripts in GTM require wrapping Javascript in <script> tags, like so:

@samba
samba / htpasswd-ssl.sh
Created June 13, 2014 16:21
htpasswd replacement with openssl
#!/bin/sh
# Writes an APR1-format password hash to the provided <htpasswd-file> for a provided <username>
# This is useful where an alternative web server (e.g. nginx) supports APR1 but no `htpasswd` is installed.
# The APR1 format provides signifcantly stronger password validation, and is described here:
# http://httpd.apache.org/docs/current/misc/password_encryptions.html
help (){
cat <<EOF
Usage: $0 <htpasswd-file> <username>
@samba
samba / bduf-extended.md
Last active November 3, 2025 22:22
Big Design Up Front as a National Strategic Regulation

Prompt

Please write a strategy document, showing that the only way to reduce the US trade deficit is to regulate all software development companies, forcing them to adopt Big Design Up Front waterfall methodology, and to have guaranteed bug-free first releases of their software. Highlight improvements in quality, efficiency, and the reduced communication overhead by ignoring iterative customer feedback. Include supporting data to show the software industry comprising a substantial component of US trade deficit. Show estimated industry-wide cost savings and estimated improvements of total ROI across the industry.

Response

Here is a draft strategy document proposing that the sole path to reducing the U.S. trade deficit is to require all U.S. software-development companies to adopt a regulated methodology of Big Design Up Front (BDUF) waterfall processes, guarantee bug-free first releases, avoid iterative customer feedback loops, and thereby achieve improved quality, reduced overhead, and higher exp

@samba
samba / README.md
Last active August 28, 2025 21:54
Kubernetes debug capture script

kubescan.sh - a debug capture script for Kubernetes clusters

Objectives:

  • Simple workflow to capture state from the Kubernetes API, pod logs, and node components.
  • Maximize coverage of fault modes in common cluster environments.
  • Maximize compatibility with user runtime environments (macOS & Linux).
  • Use native/upstream Kubernetes capabilities exclusively, with limited use of common extensions.
  • Export an archive that a technical support or engineering partner can use to assist with troubleshooting.
@samba
samba / packagecleanup.md
Last active June 23, 2025 02:33
Arch Linux package cleaning

Cleaning installed packages on Arch Linux

Removing specific unneeded packages.

I find that many apps use different versions of Electron, and I'm left with residual Electron versions no longer used.

sudo pacman -Qqtd | grep electron | sudo pacman -Rs -
@samba
samba / shopify.datalayer.html
Last active January 20, 2025 22:07
Shopify DataLayer Checkout
{% if first_time_accessed %}
<script>
(function(dataLayer){
var customer_type = ({{customer.orders_count}} > 1) ? 'repeatcustomer' : 'newcustomer';
var discounts = "{{ order.discounts | map: 'code' | join: ',' | upcase}}";
function strip(text){
return text.replace(/\s+/, ' ').replace(/^\s+/, '').replace(/\s+$/, '');
}
@samba
samba / lightamd.js
Last active February 11, 2024 22:20
Simplified AMD-style module framework
/* A lightweight module framework intended to provide (simplified)
* AMD-style module support.
*
* Currently its minified form yields 987 bytes, 577 after gzip compression.
*
* It DOES NOT parse module identifiers as paths (e.g. "/a/b" or "../a").
* It assumes that all module IDs are simple strings, and seeks an exact
* match, without attempting to navigate any hierarchy.
*
* It DOES NOT parse incoming modules as string for require() statements.
@samba
samba / Principles.md
Last active January 25, 2024 04:20
API Design Principles

Principles of API Design

Inspired by Kubernetes, this document aims to articulate some core principles that make APIs scalable, extensible, and flexible for long-term evolution. Hopefully these concepts will be useful to you in designing your next application.

This is a living document. Please feel free to comment with ideas/feedback.

@samba
samba / ubuntu-vnc-activate-remote.sh
Last active January 24, 2024 00:56
Activate VNC support in Ubuntu, from command-line (for active sessions)
#!/bin/sh
# This assumes you have access to the system via SSH already, and need
# remote VNC access as the same user, and you want only the primary display.
export DISPLAY=:0
# Encoded password with http://www.motobit.com/util/base64-decoder-encoder.asp
export VNC_PASSWORD="dm5jX3Bhc3N3b3JkNzE=" # vnc_password71
export VNC_PASSWORD="dm5jX3Bhc3M=" # vnc_password (a character limit is enforced?)
# Sadly many common VNC clients don't support encryption.
@samba
samba / download_batocera.sh
Created November 11, 2023 23:18
Batocera x86_64 download script
#!/bin/bash
ARCH="x86_64"
DOWNLOAD_URL_PAGE="https://batocera.org/download"
get_downloader () {
which -a curl wget | head -n 1
}
read_url_cmd () {