Skip to content

Instantly share code, notes, and snippets.

@mkbabb
mkbabb / 01-instructions.md
Last active May 8, 2025 16:06
DNS Resolution Test Script

I'll complete the text with the process management information:

This script performs DNS TXT record lookups once per minute for 24 hours straight. Each lookup uses a unique random name in the format 'delver-xxxxxxxx'.

Requirements

  • Python 3.x
  • Your computer must stay awake the entire time (disable sleep/hibernate)
  • Internet connection for the full 24 hours
@mkbabb
mkbabb / cache.py
Created November 1, 2024 14:54
cache-with-stale-interval
def cache_with_stale_interval(
stale_interval: datetime.timedelta | float | int | None = None,
) -> Callable[[Callable[P, R]], Callable[P, R]]:
"""
Decorator that caches function results with optional time-based invalidation.
Caching works by pickling the output alongside a JSON metadata file containing
the timestamp of the cached result. If the stale_interval is set, the cached
result is considered stale after the specified time and the function will be
re-run.
@mkbabb
mkbabb / example.py
Last active August 14, 2024 17:51
QueuePool
"""
Minimal QueuePool example with a pandas DataFrame, chunking thereof.
"""
import pandas as pd
from multiprocessing import Queue
import multiprocessing as mp
from typing import Any
import numpy as np
@mkbabb
mkbabb / geocode.py
Created August 12, 2024 19:14
Google Geocoding API Example
from typing import Any # Importing typing to specify more detailed type information
import pandas as pd # Importing pandas for data manipulation and analysis
import requests # Importing requests to make HTTP requests to external APIs
# Function to geocode an address using the Google Maps API
def geocode_address(address: str, api_key: str) -> dict[str, Any]:
# Base URL for the Google Maps Geocoding API
base_url = "https://maps.googleapis.com/maps/api/geocode/json"
@mkbabb
mkbabb / .zshrc
Last active January 28, 2025 15:25
Cross platform ZSH config
export ZSH_FRAGMENTS_DIR="$HOME/.zshrc.d"
export ZSH="$HOME/.oh-my-zsh"
mkdir -p $ZSH_FRAGMENTS_DIR
GIST_URL="https://gist.github.com/mkbabb/0b9a0052ec7fdaac6b07f684eb6ae27d/raw/7a7c2a19c23d0ac8a7c8631f91cf09c312d606f3"
CROSS_PLATFORM_FILENAME="02-cross-platform.zsh"
CROSS_PLATFORM_GIST="$GIST_URL/$CROSS_PLATFORM_FILENAME"
@mkbabb
mkbabb / introit.md
Created February 8, 2024 16:02
Reconcile school names using OpenAI's API

Integrating OpenAI and Google APIs: An Overview

This script's designed to demonstrate the integration of OpenAI's API with Google Sheets for data processing tasks. It fuzzy-finds an input school name within a list of school names, in particular, from this sheet's provided USAC school names list, and our State Valid File school names list.

Features

  • OpenAI API Usage: Uses OpenAI for fuzzy matching, facilitating comparisons between school names.
  • Google Sheets API Integration: Utilizes a bespoke utility module for seamless interaction with Google Sheets, enabling efficient data retrieval and updates.
  • Data Handling: Employs techniques for cleaning and matching data, including deduplication and filtering, to maintain data integrity and relevance.
@mkbabb
mkbabb / Chapter 1.md
Last active September 7, 2023 16:00
Chapter 1.md

1.1 Uses of Computer Networks

  • Computer networks allow remote access to information, person-to-person communication, electronic commerce, entertainment, and more.
  • The client-server model and peer-to-peer communication are common ways to access information over a network.

1.2 Types of Computer Networks

  • There are many types of networks, including broadband access networks, mobile/wireless access networks, content provider networks, transit networks, enterprise networks, and inter-networks. Each serves a different purpose and scale.
  • Local area networks (LANs) operate over a small geographic area like a building. Wireless LANs (WiFi) are very common now.

1.3 Network Technology, from Local to Global

  • Networks span a huge range of scales, from personal area networks up to the global Internet. Different technologies are used at each scale.
  • Key technologies include Ethernet for wired LANs, WiFi for wireless LANs, DOCSIS for cable broadband access, cellular technologies for mobile access, and fib
@mkbabb
mkbabb / z16 TensorFlow Example.md
Last active September 7, 2023 14:29
z16 TensorFlow Example.md

1. Install TensorFlow core 2.9

Docker within LinuxONE

List of most recent IBM z containers

Usage Notes

Exposed Ports: 8888

To start container from image & start an application in production mode:

docker run --name tensorflow -it icr.io/ibmz/tensorflow:[version] bash
@mkbabb
mkbabb / 1-user-prompt.md
Last active April 30, 2025 19:21
ChatGPT Custom Instructions

Personal Information

  • Name: [Full Name]
  • Birth Date: [Birth Date]
  • Personal Email: [Personal Email]
  • Work Email: [Work Email]
@mkbabb
mkbabb / unfurl_pdf.py
Created August 2, 2023 14:46
Unfurls a PDF into multiple, or a single, PDF
import argparse
import tempfile
import zipfile
from io import BytesIO
from pathlib import Path
from typing import Optional
import docx2pdf
import pypdf
from pypdf.generic import AnnotationBuilder