View life.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# | |
# The Game of Life in Python with no dependencies. | |
# by Brian Schrader | |
# | |
# The board is randomly generated each time so each play-through is unique! | |
# | |
# Usage: | |
# ./life.py |
View gzip_classifier.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# | |
# A basic text classifier that uses gzip. | |
# | |
# Method from https://arxiv.org/pdf/2212.09410.pdf | |
# Data from http://groups.di.unipi.it/~gulli/AG_corpus_of_news_articles.html | |
# | |
# Get newsSpace from URL above and generate files as shown below: | |
# head -100 newsSpace | tail -25 > test.txt | |
# tail -100000 newsSpace > train.txt |
View gas-sim.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
from tkinter import * | |
from tkinter.ttk import * | |
from dataclasses import dataclass | |
import math | |
from random import randint, uniform | |
View collatz.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# Fun with the Collatz Conjecture | |
from argparse import ArgumentParser | |
import csv | |
import logging | |
import matplotlib.pyplot as plt | |
import sys | |
View rocket.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
""" rocket.py -- Draw simulated rocket launches with turtle graphics | |
Sample Parameters: | |
via https://en.wikipedia.org/wiki/Falcon_9 | |
$ python3.10 rocket.py -i 282 -a 90 -r 60 -p 950 -f 3500 -b 162 | |
author: Brian Schrader | |
""" |
View pine-to-mastodon.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
View audiobookr.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 mp4.sh is in /usr/local/bin | |
# https://gist.github.com/djotto/fca0b0e57c8d008575eb7f3648260910 | |
SOURCE_DIR="$(pwd)" |
View django-unittest.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
View step-count-analysis.r
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env Rscript | |
library(zoo) | |
raw_data = read.csv('Export.csv') | |
raw_data$Date <- as.Date(raw_data$Date, "%m/%d/%y") | |
readings = data.frame( | |
dates=raw_data$Date, | |
steps=raw_data$Steps | |
) |
View mp.parallel.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 = 'https://api.pushover.net/1/messages.json' |
NewerOlder