Skip to content

Instantly share code, notes, and snippets.

samba /
Created November 11, 2023 23:18
Batocera x86_64 download script
get_downloader () {
which -a curl wget | head -n 1
read_url_cmd () {
samba /
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 / sampleId.js
Last active April 16, 2018 19:10
GTM Sampling Variable
// Sets and gets a sample ID for bucket selection in A/B and related testing methodologies.
var ckPattern = /sampleId=(\d+)/g;
var sampleId = -1;
// TODO: adopt a different method for selecting the corp top level domain
var domain = document.location.hostname;
document.cookie.replace(ckPattern, function($0, $d){
samba /
Created March 9, 2018 06:10
Extract a subset of named fields from a CSV file
#!/usr/bin/env python
# Loads a CSV file, assuming it has header names, and prints only the specified columns.
# ... like selecting two columns of a 7-column table.
# Arguments:
# - field names, comma-separated
# - input filename
# Output:
# - the header row for the specified columns, and those fields for all input records.
samba /
Last active May 22, 2019 21:52
Dump cluster state to YAML
#!/usr/bin/env bash
# bash kubeconfig.yaml > state.yaml
# Goal:
# - Provide a quick way to dump the state of a cluster for analysis
# - Simplify verification of live state of the cluster
samba / Makefile
Last active May 5, 2017 23:18
Python requirements based on Operating System
# Example dynamic selection of Python requirements files
dependencies: $(shell python
for req in $^; do \
pip install --upgrade -r $$req ; \
test: dependencies
echo run your tests.
samba /
Last active April 25, 2017 18:05
MAC Development Environment Setup
# Sets up a wide array of my development environment on a Mac...
err=$1; shift 1;
echo "$@" >&2
exit $err
samba / shopify.datalayer.html
Last active May 9, 2024 13:49
Shopify DataLayer Checkout
{% if first_time_accessed %}
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 /
Last active October 11, 2021 11:29
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 /
Created January 11, 2017 07:00
MD5 Index Scanner
#!/usr/bin/env python
Scan an index of files, typically keyed by MD5 checksum, in the format produced by
GNU `md5sum` (not BSD-style), searching for one of many checksums listed in a pattern file.
The primary objective is to help find duplicates in a large collection of files, e.g. an
archive of music. Example:
> find ./music -type f -print0 | xargs -0 md5sum | sort > index.txt