Skip to content

Instantly share code, notes, and snippets.

View AceofSpades5757's full-sized avatar
🌐
Homelab Maintenance

Kyle L. Davis AceofSpades5757

🌐
Homelab Maintenance
View GitHub Profile
@AceofSpades5757
AceofSpades5757 / startup.py
Created June 26, 2024 15:38
IPython Profile for Taskwarrior
"""Startup files for my IPython Taskwarrior profile.
File is located in ~/.ipython/profile_task/startup
Script is run when running `ipython --profile task`
"""
import platform
from tasklib import TaskWarrior
from tasklib import Task
@AceofSpades5757
AceofSpades5757 / add_bg_to_png.py
Last active April 12, 2024 04:17
Add a background to a PNG file
#!/usr/bin/env pip-run
"""Takes a PNG file, adds a white background to it, and copies it to the
clipboard.
Uses `pip-run` to run the script with the required packages installed.
This script is licensed under the MIT License.
Copyright © 2024 Kyle L. Davis
"""
__requires__ = ["Pillow", "pywin32"]
@AceofSpades5757
AceofSpades5757 / cargo.toml
Created June 9, 2022 02:06
In a browser, set the clipboard (WASM)
[package]
name = "set-web-clipboard"
version = "0.1.0"
edition = "2021"
[dependencies]
# JavaScript in Rust
wasm-bindgen = "0.2" # May not be needed
web-sys = { version = "0.3", features = ["Clipboard"] }
@AceofSpades5757
AceofSpades5757 / docx_helpers.py
Created February 16, 2022 05:26
DOCX Helper Functions
""" Helpers for working with docx files.
Currently includes a couple functions for adding additional permissions to
protect contents of the document.
"""
import string
import random
import lxml.etree
from docx.oxml.settings import CT_Settings
@AceofSpades5757
AceofSpades5757 / async_example.py
Last active April 15, 2021 01:20
Example of async usage in Python by pulling and checking the status of local repos.
""" Pull Git repos and check the status of them using Python's async.
Simple test using async subprocess calls and async itself.
Some simple tests showed this took a 3rd the time of the synchronous
counterpart.
"""
import asyncio
import time
from pathlib import Path
@AceofSpades5757
AceofSpades5757 / open_urls.py
Last active June 28, 2021 03:10
Open a list of URLs on Windows
""" Opens URLs in the default browser.
I use this a lot when I need to open a whole lot of URLs at the same time.
1. Takes in a hard-coded set of `items`.
2. Generates a safe URL from `item`.
3. Passes each item to `get_url` to get the URL to open.
4. Opens each URL with built-in `webbrowser` package, delayed by `delay`.
Inputs