Skip to content

Instantly share code, notes, and snippets.

@andrewbolster
andrewbolster / migrate_ownership.py
Created February 2, 2024 15:23
As part of a Atlassian merge+migration where we needed to have all _old_ useraccounts manually migrate their content to _new_ user accounts, to then have the whole instance merged, I didn't want to go through 300 pages of updates. So I wrote this.
from tqdm.auto import tqdm
from requests.exceptions import HTTPError
from getpass import getpass
import os
from atlassian import Confluence
def get(label):
if label not in os.environ:
os.environ[label]=getpass(f'Enter {label}')
@andrewbolster
andrewbolster / fuvm.py
Created January 18, 2022 13:17
How to log when connections drop.
"""usage
python fuvm.py <external canary URL>
"""
import time
import socket
import requests
import sys
import logging
class CustomFormatter(logging.Formatter):
@andrewbolster
andrewbolster / import_repo.sh
Last active June 23, 2020 14:25
Git Merge Hellscape
#!/bin/bash
usage() {
cat << EOF
This script imports a git repo (accessible from https://\$origin/\$user/\$repo) and all its history as subdirectory of a destination (available locally at \$dest)
It is designed for non-production, archival processes and may destroy everything you've ever loved because you looked at it funny. You have been warned.
The structure of the destination will end up something like this:
~/src
- \$dest
- origins
x, *xs, y, z = map(lambda j: lambda i: j**i ,range(1, 10))
x(2),y(2),z(2)
@andrewbolster
andrewbolster / vimrc
Created October 20, 2015 09:46
My Fucked VIMrc
" Pathogen : https://github.com/tpope/vim-pathogen
execute pathogen#infect()
set nocompatible " be iMproved
filetype off " required!
" Setting up Vundle - the vim plugin bundler
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
#!/bin/bash
# Example script to start up tunnel with autossh.
# This script will tunnel 22 from the local host
# to 11122 on the remote host. If that post isn't
# availabile it'll increment. Also does the same
# with 8888/11188 for ipython notebook
# REQUIRED autossh
HOST=${@: -1}
REMOTE_SSH_PORT=11122
REMOTE_HTTP_PORT=11188
@andrewbolster
andrewbolster / spoitfy error log
Created May 18, 2015 14:57
Spotify error log after having cleared .cache/spotify directory
bolster@yossarian ~/.cache
➜ spotify 5779-[14:36:24]
13:36:27.454 I [breakpad.cpp:110 ] Registered Breakpad for product: spotify
13:36:27.455 I [translate.cpp:152 ] Reloading language file
13:36:27.465 I [translate.cpp:152 ] Reloading language file
13:36:27.466 I [breakpad.cpp:269 ] Searching for crashdumps: /home/bolster/.cache/spotify/*.dmp
13:36:31.617 I [offline_authorizer.cpp:278 ] Unable to login offline: no such user
13:36:36.722 I [ap_connection_impl.cpp:901 ] Connecting to AP lon2-accesspoint-a33.ap.spotify.com:4070
@andrewbolster
andrewbolster / observium_discoverer
Created April 24, 2015 15:02
SNMP Monitoring and Configuration for Networks and Linux Host Monitoring
# Note: This file lives on the observium server inside /etc/cron.d/
13 * * * * root host -t axfr anrg.liv.ac.uk | awk '$4 ~ "^A$" {print $1}' > /dev/shm/devices 2> /dev/null; /opt/observium/add_device.php /dev/shm/devices >> /dev/null 2>&1
@andrewbolster
andrewbolster / imgurlinker.py
Created April 2, 2015 13:47
imgur arbitrary URL parser and decomposer
import urllib2
from time import sleep
from imgurpython import ImgurClient
from imgurpython.helpers.error import ImgurClientError, ImgurClientRateLimitError
def imgurlinker(x):
global client
try:
defrag = urllib2.urlparse.urldefrag(x)[0] # To deal with post-url items eg "#0"
@andrewbolster
andrewbolster / Lawnmower.ipynb
Created September 5, 2014 09:04
Lawnmower Process
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.