Skip to content

Instantly share code, notes, and snippets.

View cablespaghetti's full-sized avatar

Sam Weston cablespaghetti

View GitHub Profile
@FSX
FSX / script.lua
Last active December 21, 2023 15:34 — forked from chanks/script.lua
Lua script to delete/trim all processed messages from a Redis stream
-- The goal of this script is to trim messages that have been processed by
-- all extant groups from the a given Redis stream. It returns the number
-- of messages that were deleted from the stream, if any. I make no
-- guarantees about its performance, particularly if the stream is large
-- and not fully processed (so a simple XTRIM isn't possible).
-- First off, bail out early if the stream doesn't exist.
if redis.call("EXISTS", KEYS[1]) == 0 then
return false
end

I've been working with Apache Kafka for over 7 years. I inevitably find myself doing the same set of activities while I'm developing or working with someone else's system. Here's a set of Kafka productivity hacks for doing a few things way faster than you're probably doing them now. 🔥

Get the tools

@giannivh
giannivh / keycloak_impex.sh
Last active September 18, 2020 06:57 — forked from unguiculus/keycloak_impex.sh
Import/Export Keycloak Config running on Kubernetes
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
show_help() {
cat << EOF
Usage: $(basename "$0") <options>
-h, --help Display help
@manicminer
manicminer / README.md
Last active January 25, 2024 12:27
Ansible invocation with assumed IAM role

Ansible invocation with assumed IAM role

How it works

  • boto3 initializes a session using the specified profile, for which it assumes a role as configured in your ~/.aws/config
  • Python script with above session initialization prints out shell-compatible environment variables of the temporary credentials
  • Wrapper script sets these a la eval
  • By the time Ansible runs, the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SECURITY_TOKEN (for boto2) / AWS_SESSION_TOKEN (for boto3) are all set, and are consumed by boto2 in the inventory script and other boto2-based modules

Notes

@tsub
tsub / remove-untagged-images-for-ecr
Created August 16, 2017 08:10
Remove untagged images for ECR
#!/bin/sh
set -eu
type aws > /dev/null 2>&1 && type jq > /dev/null 2>&1 || {
echo 'Required aws-cli and jq'
exit 1
}
repositories=$(aws ecr describe-repositories --query 'repositories[*].repositoryName' | tr -d "[\",\t\n\r\"]")

Install certbot

sudo su
yum install wget -y
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto

Install certificate

@itay-grudev
itay-grudev / README.md
Last active March 19, 2021 19:53
BT WiFi Maintain Connectivity Script

BT WiFi Maintain Connectivity Script

Usage

btauth --user USER_OR_EMAIL --pass PASSWORD # To Authenticate with the BT WiFi
btmaintain --user USER_OR_EMAIL --pass PASSWORD # To maintain a connection and re-authenticate automatically
nohup btmaintain --user USER_OR_EMAIL --pass PASSWORD 2&gt;&amp;1 &gt;/dev/null &amp; # Same as above but ran in background