Skip to content

Instantly share code, notes, and snippets.


Brian Schrader Sonictherocketman

View GitHub Profile
Sonictherocketman /
Created March 10, 2023 08:59
A simple rocket simulation in Python.
#! /usr/bin/env python3
""" -- Draw simulated rocket launches with turtle graphics
Sample Parameters:
$ python3.10 -i 282 -a 90 -r 60 -p 950 -f 3500 -b 162
author: Brian Schrader
Sonictherocketman /
Created March 10, 2023 03:26
A script to automatically cross-post from to Mastodon.
#! /usr/bin/env python3
import argparse
from bs4 import BeautifulSoup
from contextlib import contextmanager
from datetime import datetime
import markdown
import json
import httpx
import sys
import uuid
Sonictherocketman /
Created March 1, 2023 04:12
A script to turn large text documents into audiobooks with chapters.
#! /usr/bin/env zsh
# Given a text file, split it into chapters, then make audio for each
# chapter using a set of presets. Then join the audio together
# preserving each chapter in the metadata.
# This assumes is in /usr/local/bin
Sonictherocketman /
Created February 16, 2023 22:36
ChatGPT Code Samples
from django.urls import reverse
from rest_framework.test import APITestCase
from rest_framework import status
from .models import User
class UserTests(APITestCase):
def test_create_user(self):
Ensure we can create a new user object.
Sonictherocketman / step-count-analysis.r
Created August 29, 2022 22:24
A script to process and chart step count data exported from Pedometer++ for iOS.
View step-count-analysis.r
#! /usr/bin/env Rscript
raw_data = read.csv('Export.csv')
raw_data$Date <- as.Date(raw_data$Date, "%m/%d/%y")
readings = data.frame(
Sonictherocketman /
Created August 28, 2022 23:23
Multiplicative Persistence Calculations in Python
#! /usr/bin/env pypy3
# Find a number with a multiplicative persistance larger than 11.
from collections import Counter
from functools import reduce
from multiprocessing import Pool
import json
import requests
import time
URL = ''
Sonictherocketman /
Created August 16, 2022 22:45
Continual Pressure/Temperature Monitoring (run on a cronjob)
# I didn't write this code. I just found it online.
# make sure to install python-smbus using below command
# sudo apt-get install python-smbus
import smbus
import time
from ctypes import c_short
DEVICE = 0x77 # Default device I2C address
Sonictherocketman /
Created August 23, 2021 22:46
A terrible way to calculate the absolute value of a number in Python.
# A terrible way to calculate the absolute value of any integer with no reliance on complex computer math!
# Do not do this.
# Usage:
# >>> abs(10)
# 10
# >>> abs(-10)
# 10
# >>> abs(10.2)
# 10.2
Sonictherocketman /
Created April 3, 2021 20:28
A personalized weekly Pinboard-based newsletter of pages you said you wanted to read.
set -e;
# Creates a simple email message containing links from your recent Pinboard
# bookmarks that are marked as "to read".
echo "[$(date)] Beginning pinboard weekly summary...";
TO="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
#! /bin/bash
# A basic CentOS Setup Script
echo "[$(date)] Starting Base Installs"
sudo yum -y update
sudo yum install -y tmux git epel-release htop
echo "[$(date)] Installing Docker"
sudo yum -y install docker docker-registry
sudo systemctl enable docker.service