Skip to content

Instantly share code, notes, and snippets.

View rblaine95's full-sized avatar
💭
Using poison pills to kill orphaned children

Robbie Blaine rblaine95

💭
Using poison pills to kill orphaned children
  • Stellenbosch, South Africa
  • 13:28 (UTC +02:00)
View GitHub Profile
@rblaine95
rblaine95 / bringing-old-photo-back-to-life.ipynb
Last active March 20, 2023 14:30
bringing-old-photo-back-to-life.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rblaine95
rblaine95 / parallel-s3-delete.sh
Last active March 2, 2023 16:13
Delete objects in S3 older than 150d in parallel
BUCKET="this-is-not-proprietary"
JOBS=8
aws s3api list-objects --bucket "$BUCKET" --query \
"Contents[?LastModified<=\`$(date -v-150d '+%Y-%m-%d')\`][].{object: Key}" \
| jq -r '.[].object' \
| parallel -j$JOBS --colsep {} aws s3 rm s3://$BUCKET/{}
@rblaine95
rblaine95 / permutationsort.py
Last active October 22, 2021 10:10
Permutation Sort - Given a list, generate every possible permutation of the list, then find the one that's sorted
#!/usr/bin/env python3
import itertools
from random import shuffle
def is_sorted(l):
for i in range(len(l)-1):
if l[i] > l[i+1]:
return False
return True
@rblaine95
rblaine95 / bogosort.py
Last active October 22, 2021 08:53
Bogosort - So long as a list is not sorted, randomize the order
#!/usr/bin/env python3
from random import shuffle
def bogosort(l):
while not is_sorted(l):
shuffle(l)
return l
def is_sorted(l):
for i in range(len(l)-1):

Keybase proof

I hereby claim:

  • I am rblaine95 on github.
  • I am cpt_pi (https://keybase.io/cpt_pi) on keybase.
  • I have a public key ASBWjpbqjxosW7rfmt0Cc7ySfEICzFiHzXGPSp7wL0W0IQo

To claim this, I am signing this object:

import csv
import os
import string
import random
import subprocess
import sys
def main(arg):
try:
PWD_SIZE = 20
#opens CSV file of desired new users
@rblaine95
rblaine95 / archlist.sh
Last active February 9, 2021 09:07
Get the latest Arch Linux mirrorlist for the country that corresponds to your IP
#!/bin/sh
curl -s https://archlinux.org/mirrorlist/\?country\=$(curl -s https://ifconfig.co/country-iso)\&protocol\=http\&protocol\=https\&ip_version\=4 | sed 's/\#S/S/g'
@rblaine95
rblaine95 / dockerhub.sh
Last active July 23, 2018 10:54
Query DockerHub for a list of all images and image tags associated with a user account, then pull all of them, tag them with a new registry, push them, and then delete them from the localhost.
#!/bin/bash
# Example for the Docker Hub V2 API
# Returns all imagas and tags associated with a Docker Hub user account.
# Requires 'jq': https://stedolan.github.io/jq/
# set username and password
UNAME=""
UPASS=""
REGISTRY_URL="localhost:5000"
@rblaine95
rblaine95 / docker-migrate.sh
Last active July 20, 2018 11:58
Pull all images+tags belonging to $repo on $old registry, tag the images with $new registry name, push all images to $new registry, and delete the images after
#!/bin/bash
$old=old.registry.net:5000
$new=new.registry.net:5000
$repo=""
# Batch pull, tag, push, delete
batch() {
for x in `wget -q http://$old/v2/_catalog -O - | sed -e 's/[][]//g' -e 's/\,/\n/g' -e 's/\"//g' -e 's/\}//g' | grep $repo | tr '\n' ' '`; do docker pull $old/$x -a; done
docker images | grep $old | awk -F' ' '{ print $1":"$2 }' | awk -F '/' '{ print "docker tag "$1"/"$2"/"$3" $new/"$2"/"$3 }' | xargs -L 1 xargs
docker images | grep $new | awk -F' ' '{ print $1":"$2 }' | awk -F '/' '{ print "docker push "$1"/"$2"/"$3 }' | xargs -L 1 xargs