Skip to content

Instantly share code, notes, and snippets.

@djpadz
djpadz / create-token-for-azure-devops-sa.sh
Last active January 4, 2023 23:06
Azure DevOps: Authenticate using your subscription to AKS >= 1.24
#!/bin/bash
ns="$1"
if [[ -z ${ns} ]]; then
echo "Usage: $0 <namespace>" >&2
exit 1
fi
echo "Watching for an azdev service account in namespace ${ns}..."
@djpadz
djpadz / brew-make-dependent-only
Last active January 4, 2023 23:05
Homebrew: make a bottle dependent-only
#!/usr/bin/env python3
import json
import sys
import os
kvp = (("installed_as_dependency", True), ("installed_on_request", False))
for i in sys.argv[1:]:
filename = f"/usr/local/opt/{i}/INSTALL_RECEIPT.json"
@djpadz
djpadz / 5000-toot-size-patch.sh
Last active February 11, 2023 00:31
Patch the mastodon server to allow 5000-character toots
#!/bin/bash
# Last tested version: 4.1.0
set -e
set -x
cd "${BASH_SOURCE%/*}"
patch -p0 <<'EOF'

Keybase proof

I hereby claim:

  • I am djpadz on github.
  • I am djpadz (https://keybase.io/djpadz) on keybase.
  • I have a public key ASDEsUW5qCKwcqhIuFwjxBe3yo_v4_7daSKJBWEW-aGAtwo

To claim this, I am signing this object:

@djpadz
djpadz / aws-docker-login.rb
Created April 15, 2020 19:08
Log in to a docker repository in AWS ECR using the current profile
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'json'
require 'base64'
require 'open3'
puts 'Getting authorization token...'
out, status = Open3.capture2 'aws', 'ecr', 'get-authorization-token'
@djpadz
djpadz / cidr-reduce.pl
Created April 13, 2020 20:18
PERL script that takes a list of CIDRs and reduces them to a minimal set
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my @ips;
sub ipCmp($$) {
my $ip1 = shift;
my $ip2 = shift;
@djpadz
djpadz / shexp_match.pl
Last active February 19, 2020 21:45
PERL: Match a shell expression
#!/usr/bin/perl
sub shexp_match {
my $shexp = shift;
my $word = shift;
# Translate a shell expression into a regular expression
my $re = $shexp;
# Convert all .'s into quoted .
$re =~ s/\./'\.'/ge;
@djpadz
djpadz / Dockerfile
Last active February 5, 2020 19:44
Dockerfile to build s6 RPMs under OEL 7
FROM oraclelinux:7-slim
ARG skalibs_version=2.9.1.0
ARG s6_version=2.9.0.1
ARG execline_version=2.5.3.0
ARG ruby_version=2.6
RUN true \
&& yum-config-manager --enablerepo=ol7_optional_latest \
@djpadz
djpadz / mm.rb
Last active September 22, 2019 23:42
Ruby: "MasterMind" solver
#!/usr/bin/env ruby
require 'set'
class GameBoard
attr_reader :boxes, :colors, :scheme
def initialize(colors, boxes, scheme = nil)
raise ArgumentError.new("scheme has #{scheme.length} elements; expecting #{boxes}") if scheme && scheme.length != boxes
@djpadz
djpadz / dowifi.sh
Created April 18, 2019 07:46
macOS: MAC address spoofing
#!/bin/bash
(( $(id -u) == 0 )) || exec sudo -E "$0" "$@"
# Set ATV_MAC to the MAC address of your Apple TV.
[[ -z $ATV_MAC ]] && ATV_MAC='aa:bb:cc:dd:ee:ff'
[[ -z $AIRPORT_INTERFACE ]] && AIRPORT_INTERFACE="$(networksetup -listnetworkserviceorder | grep -F 'Hardware Port: Wi-Fi' | awk '{print substr($NF,1,length($NF)-1)}')"
[[ -z $SSID ]] && SSID=$(networksetup -getairportnetwork "${AIRPORT_INTERFACE}" | cut -c24-)
[[ -z $ORIG_MAC ]] && ORIG_MAC="$(ifconfig "${AIRPORT_INTERFACE}" link | tail -1 | awk '{print $NF}')"