Skip to content

Instantly share code, notes, and snippets.

View robvanderleek's full-sized avatar
💭
👋 Hello Internet

Rob van der Leek robvanderleek

💭
👋 Hello Internet
View GitHub Profile
@robvanderleek
robvanderleek / s3prune.py
Created September 5, 2018 22:47
Prunes folder (all object versions and delete markers) on S3
#!/usr/bin/env python
# Prunes folder (all object versions and delete markers) on S3
import boto3
import sys
if len(sys.argv) != 3:
print('usage: {} <bucket> <prefix>'.format(sys.argv[0]))
sys.exit(1)
if sys.argv[2] == '/':
@robvanderleek
robvanderleek / README.md
Last active December 25, 2020 12:34
Auto-merge Dependabot Pull-Requests

Auto-merge Dependabot Pull-Requests

Since Dependabot was acquired by GitHub the native Dependabot auto-merge functionality stopped working, This is a way to re-enable that functionality for a repository.

  1. Create a Dependabot configuration YAML (look here for the syntax) for your repository in .github/dependabot.yml, for example:
version: 2
updates:
- package-ecosystem: npm
@robvanderleek
robvanderleek / README.md
Last active April 13, 2022 03:14
Simple RTSP test server

Simple RTSP test server

Sometims you just need to have a local RTSP stream to test your software against. The attached script start-rtsp-stream.sh does just that. It requires Docker and ffmpeg and can be launched with zero arguments to give you an RTSP stream of a looped video:

$ ./start-rtsp-stream.sh
Stopping server (if running)...
Starting simple RTSP server...
Starting video stream at: rtsp://localhost:8554/live.stream
@robvanderleek
robvanderleek / index.js
Created September 28, 2020 21:57
Backpack issue #3
#!/usr/bin/env node
const fs = require('fs');
const os = require('os');
const path = require('path');
function usage() {
console.log(
'Backpack usage:\n' +
' Put in backpack: bp -i <filename>\n' +
' Get from backpack: bp -e <filename>\n')
@robvanderleek
robvanderleek / index.js
Created September 30, 2020 06:59
Backpack issue 5
diff --git a/index.js b/index.js
index 3cbc816..03e0acb 100755
--- a/index.js
+++ b/index.js
@@ -6,6 +6,7 @@ const path = require('path');
function usage() {
console.log(
'Backpack usage:\n' +
+ ' List files in backpack: bp -l\n' +
' Put in backpack: bp -i <filename>\n' +
@robvanderleek
robvanderleek / README.md
Last active January 18, 2024 13:09
Show current Git branch in iTerm2

Show current Git branch in iTerm2

Terminal

If you want your iTerm2 terminal window display the current Git branch (when the current directory is inside a Git repository of course) add the following to your .zshrc:

set_terminal_title() {
@robvanderleek
robvanderleek / README.md
Last active March 11, 2024 19:56
AWS SSO command-line login script (that also updates .aws/credentials)

AWS SSO command-line login script (that also updates .aws/credentials)

The AWS Command Line Interface tool from Amazon (for macOS available here on Homebrew) makes it possible to login to AWS through a SSO (Single Sign-On) identity provider such as Okta. However, if you login via "aws sso login" the AWS credentials file (located at ~/.aws/credentials) is not updated, this is a problem for tools/libraries that rely on that file.

This script is a wrapper around aws sso login that also updates the .aws/credentials file. It only requires AWS CLI and Python 3 to run.

Configuration

Make sure your .aws/config file has a section (or multiple sections) that have SSO configuation options. For example:

#!/bin/bash
IFS=
banner=`cat /dev/stdin | figlet -w 999`
columns=`tput cols`
spacer=`cat /dev/zero | head -c $columns | tr '\0' ' '`
banner_with_spacer=`echo $banner | sed "s/^/$spacer/"`
banner_length=`echo $banner_with_spacer | awk '{print length}' | head -n 1`
start_index=1
while true
do
#!/bin/tcsh
IFS=:
set tempfile=`mktemp`
cat /dev/stdin | figlet -w 999 > $tempfile
set columns=`tput cols`
set spacer_cmd="cat /dev/zero | head -c $columns | tr '\0' ' '"
sed -i.bak "s/^/`$spacer_cmd`/" $tempfile
set banner_length=`cat $tempfile | awk '{print length}' | head -n 1`
set start_index=1
while (1)
@robvanderleek
robvanderleek / README.md
Last active November 20, 2021 12:02
Fixing a cascading delete problem in SQLAlchemy

Fixing a cascading delete problem in SQLAlchemy

Recently I spent two days figuring out why a seemingly trivial use of a cascading delete relationship in SQLAlchemy did not work properly, eventually I found the answer in this StackOverflow post. Because it was a real puzzler I've created this short writing, perhaps it can be of help to someone facing the same problem someday.

The context of the problem is very simple: there are two tables (Parent and Child), each Parent can only have one Child and when a Parent row is deleted the associated Child row should also be deleted.

This is how that looks in SQLAlchemy Python code:

class Child(Base):