Skip to content

Instantly share code, notes, and snippets.

View mthomason's full-sized avatar
👻

Michael Thomason mthomason

👻
View GitHub Profile
@mthomason
mthomason / following_export.py
Created March 5, 2025 16:06
Throwaway Python 3 script using to list Twitter-X followers.
import asyncio
import getpass
from typing import List, Dict
from twscrape import API, gather # type: ignore
OUTPUT_FILE = "following_export.txt" # Hardcoded output file name
async def get_following_accounts(target_username: str, api: API) -> List[Dict[str, str]]:
"""
Fetch the accounts that the given target user follows.
@mthomason
mthomason / quotes.sql
Last active March 5, 2025 01:49
Quotation dictionary for Quotationary app for iOS.
This file has been truncated, but you can view the full file.
/* WARNING: Script requires that SQLITE_DBCONFIG_DEFENSIVE be disabled */
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE favorites (author TEXT, quote TEXT);
CREATE TABLE favs (fav integer);
CREATE TABLE categories (id INTEGER PRIMARY KEY, category TEXT);
INSERT INTO categories VALUES(0,'Uncategorized');
INSERT INTO categories VALUES(1,'Age');
INSERT INTO categories VALUES(2,'Anger');
INSERT INTO categories VALUES(3,'Art');
@mthomason
mthomason / testTryCatch.ts
Created February 26, 2025 13:27
A fixed version of an tryCatchWrapper for TypeScript.
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@mthomason
mthomason / create_quadrant_chart.py
Created January 30, 2025 11:14
Python 3 function to create a political quadrant chart. Uses `matplotlib`.
import matplotlib.pyplot as plt
import matplotlib.patches as patches
def create_quadrant_chart(
quadrant_labels,
quadrant_colors,
axis_labels,
arrow_props=None,
text_bbox=None,
figsize=(8, 8),
@mthomason
mthomason / add_creation_date_to_obsidian_files.py
Created January 22, 2025 17:22
Python script to add date-created property to Obsidian Markdown files.
# Add date created to Obsidian files, if they don't already exist.
import os
import datetime
import re
def get_creation_date(filepath):
"""Get the creation date of a file."""
stat = os.stat(filepath)
try:
@mthomason
mthomason / create-notes-index.py
Last active January 21, 2025 15:51
Create an Index file for daily notes. Edit script to add path to your vault. May also need to edit the regex for the date format.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Michael Thomason <[email protected]>
# Copyright (C) 2025 Michael Thomason, All rights reserved.
# License: MIT
# Daily Journal Index Generator
#
# This script generates an index file for daily journal notes stored in a specific directory.
@mthomason
mthomason / create-notes-index-full.py
Last active January 21, 2025 17:59
Create an `Index.md` file for an Obsidian vault. Edit script to add path to your vault.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Author: Michael Thomason <[email protected]>
# Copyright (C) 2025 Michael Thomason, All rights reserved.
# License: MIT
# Obsidian Vault Index Generator
#
# This script generates an index for an Obsidian vault by scanning all markdown files
@mthomason
mthomason / buildcounter.sh
Created November 24, 2024 16:14
This is a build counter for Xcode projects. Update paths and create a run-script build phase.
#!/bin/sh
# buildcounter.sh
# MAD
#
# Created by Michael Thomason on 3/4/14.
# Copyright © 2017 Michael Thomason. All rights reserved.
# Build Counter Script for Xcode
# This script updates version/build metadata using git information and PlistBuddy.
@mthomason
mthomason / MADMathAlgebra.h
Created November 21, 2024 10:24
Slope, intercept, distance, etc., between points.
//
// MADMathAlgebra.h
// MADCocoaExtensions
//
// Created by Michael Thomason on 5/23/16.
// Copyright © 2017 Michael Thomason. All rights reserved.
//
#ifndef MADMathAlgebra_h
#define MADMathAlgebra_h
@mthomason
mthomason / MTTree.h
Last active November 20, 2024 08:43
This is a basic tree structure in Objective-C.
//
// MTTree.h
// libMTDataStrutures
//
// Created by Michael Thomason on 6/21/14.
// Copyright © 2024 Michael Thomason. All rights reserved.
//
#ifndef MAD_DataStructures_MTTree_h
#define MAD_DataStructures_MTTree_h