Skip to content

Instantly share code, notes, and snippets.

x, *xs, y, z = map(lambda j: lambda i: j**i ,range(1, 10))
x(2),y(2),z(2)
@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
@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 / 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}')
import nltk
import random
from nltk.corpus import brown
# Ensure the necessary NLTK resources are downloaded
nltk.download('brown')
nltk.download('universal_tagset')
def get_common_words_by_pos(tag, num_words=100):
""" Return a list of the most common words for a given part of speech tag """
@andrewbolster
andrewbolster / main.py
Created April 21, 2024 16:40
Better Statement Generator
import typing as t
import logging
import random
from fastapi import Depends, FastAPI, Header, HTTPException
from fastapi.security.http import HTTPAuthorizationCredentials, HTTPBearer
from pydantic import BaseModel
from starlette import status
from os import environ