Skip to content

Instantly share code, notes, and snippets.

View ottter's full-sized avatar

James ottter

View GitHub Profile
@ottter
ottter / mongodb-download.py
Last active April 21, 2023 16:39
Download all images in a MongoDB Collection
import os
import wget
import uuid
import requests
from pymongo import MongoClient
# Meant for my discord quotes database, but works for anything where collection looks like:
# {
# { 'name': '<name>',
# 'image_url: '<url>'
@ottter
ottter / terraform-format.yml
Created May 1, 2023 21:24
Automatically format terraform code, including make the PR and merge
name: Setup Terraform via GitHub Actions
# Source: https://github.com/marketplace/actions/hashicorp-setup-terraform
on: [push, pull_request]
#on:
# push:
# branches:
# - main
env:
@ottter
ottter / grandexchange.py
Last active May 5, 2023 18:48
Dynamically load and unload subclassed buttons in Discord.py 2.0. Edit a message depending on the button being pressed.
# ----------
# Example is using Runescape Grand Exchange. User searches for an item and 'closest_item' is returned.
# Buttons for each of the 'closest_item' are generated and user clicks on which one they want. Message
# updates based on that selection and all the buttons are removed.
# ----------
# message_author = context.message.author # If using commands, different if using slash
# closest_items = ['Runite bar', 'Bronze bar', 'Iron bar', 'Rune dart']
# game = 'osrs'
# view = GrandExchangeView(context.message.author, closest_items, game)
# embed = preselect_embed(game) # content of the embed doesn't matter in this context
@ottter
ottter / export-aws-creds.sh
Last active May 12, 2023 18:48
Quickly send AWS connection variables from one server to another
#!/bin/bash
# Prerequisites
# - active `AWS_SESSION_TOKEN`, `AWS_SECRET_ACCESS_KEY`, and `AWS_ACCESS_KEY_ID` on host server
# - identity file for the remote server, if required by server
# Get command-line arguments
while getopts ":s:i:" opt; do
case $opt in
s) remote_server="$OPTARG"
@ottter
ottter / environment.yml
Created July 19, 2023 18:48
Tortoise TTS w/ CUDA on Windows
name: tortoise
channels:
- conda-forge
dependencies:
- python=3.8
- charset-normalizer
- pip
- pillow
@ottter
ottter / conda.md
Created August 13, 2023 03:50
Conda QoL

Linux terminal (super) lite:
conda install m2-base