Skip to content

Instantly share code, notes, and snippets.

View stuaxo's full-sized avatar
💭
 

Stuart Axon stuaxo

💭
 
View GitHub Profile
@stuaxo
stuaxo / utm-linux-vm-playbook.md
Last active August 10, 2023 17:19
Ubuntu VM in a Mac Host [QEmu with UTM frontend]
@stuaxo
stuaxo / download_file.sh
Last active July 16, 2023 00:56
Download a file using intermediate .part file and automatically resume.
#!/bin/bash
# Function to handle the download
download_file() {
local delete_flag="${1:-false}"
local url="$2"
local filename="$3"
# Extract filename from URL if not provided
if [ -z "$filename" ]; then
@stuaxo
stuaxo / download-gist.sh
Last active May 15, 2023 22:08
Download all files in a github gist to the current directory
#!/bin/bash
#
# Download all the files in a GitHub Gist
#
# Example usage:
# $ download-gist.sh https://gist.github.com/stuaxo/2e110aaa42050490ad3fd73cfbedf76a
#
# By default, files are not overwritten. The -f option overrides this behavior:
# $ download-gist.sh -f https://gist.github.com/stuaxo/2e110aaa42050490ad3fd73cfbedf76a
#
@stuaxo
stuaxo / download-ow1.9.sh
Last active July 16, 2023 00:57
Install openwatcom-1.9 on Linux
#!/bin/bash
#
# Download open watcom 1.9 from sourceforge.
#
# Requires curl or wget
FILENAME="open-watcom-c-linux-1.9"
URL="https://master.dl.sourceforge.net/project/openwatcom/open-watcom-1.9/$FILENAME"
# Check if curl is available
if command -v curl >/dev/null 2>&1; then
@stuaxo
stuaxo / dirtogpt.py
Last active April 18, 2024 22:13
List filenames and content ready for input to a LLM - optionally copy to the clipboard with a prompt.
#!/usr/bin/env python3
# Usage: python dirtogpt.py [--dir /path/to/directory] [--glob *.py] [--prompt [Custom prompt]] [--copy] [--exclude *.pyc]
import argparse
import pathlib
import fnmatch
try:
import pyperclip
@stuaxo
stuaxo / hyperlink.sh
Last active July 16, 2023 00:57
Output OSC-8 hyperlink in the terminal
@stuaxo
stuaxo / sys_path_via_dotenv.py
Created February 3, 2023 12:34
Update sys.path if PYTHONPATH is changed by dotenv
def update_paths():
import os
import sys
import dotenv
dotenv.load_dotenv(override=True)
new_paths = {*os.environ["PYTHONPATH"].split(":")} - set(sys.path)
sys.path.extend(new_paths)
@stuaxo
stuaxo / concat_non_null_fields.py
Created April 5, 2022 12:32
Django concatenate non null fields. #snippet
# Ended up not using this, as there was only one place in the codebase.
def concat_non_null_fields(fields, seperator):
"""
Build a case statement expression to concatenate the supplied fields where isnull is False.
:param fields: List of fields to concatenate.
:param seperator: Seperator to use between fields.
:return: Case statement expression.
@stuaxo
stuaxo / 70-snap.core.rules.d
Created August 31, 2021 17:06
70-snap.core.rules.d
# This file is automatically generated.
# Concatenation of all ModemManager udev rules
# do not edit this file, it will be overwritten on update
ACTION!="add|change|move", GOTO="mm_cinterion_port_types_end"
SUBSYSTEM!="tty", GOTO="mm_cinterion_port_types_end"
ENV{ID_VENDOR_ID}!="1e2d", GOTO="mm_cinterion_port_types_end"
SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="?*", ENV{.MM_USBIFNUM}="$attr{bInterfaceNumber}"
@stuaxo
stuaxo / cairo-svg-how-to-fill-and-stroke.ipynb
Last active March 24, 2021 01:26
OPERATOR_SOURCE and OPERATOR_CLEAR create images in SVGs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.