Skip to content

Instantly share code, notes, and snippets.

View franklindyer's full-sized avatar
🤔
doing lots and lots of math

Franklin Pezzuti Dyer franklindyer

🤔
doing lots and lots of math
View GitHub Profile
@franklindyer
franklindyer / battery_tracker.py
Created March 19, 2023 20:30
Simple python script using bluetooth to periodically log your phone's battery level from another device.
import asyncio
from bleak import BleakClient, BleakScanner
import time
from datetime import datetime
import sys
print("Bluetooth battery monitoring script launched.")
args = sys.argv
if len(args) < 3:
{-
Terminal-based Sokoban in Haskell
Author: Franklin P. Dyer
Run in the same directory as a text file of Sokoban levels
entitled "levels.txt". These should be encoded in the usual way:
# - wall
- empty (whitespace)
$ - crate
. - goal
* - crate on goal
"""
A minimal example of using apscheduler
to schedule regularly recurring tasks.
"""
from datetime import datetime, timedelta
from apscheduler.schedulers.blocking import BlockingScheduler
# A sample job
def my_job(msg):
@franklindyer
franklindyer / gist:206daab8a0f878881b5d46fc79e5696e
Created August 27, 2023 19:20
Struct casting example with IP address (little-endian)
#include <stdio.h>
#include <stdint.h>
struct ip4 {
uint8_t first;
uint8_t second;
uint8_t third;
uint8_t fourth;
};
@franklindyer
franklindyer / memorymacros
Last active September 14, 2023 21:52
Brainfuck memory-management macro expander
# Some useful macros for readable Brainfuck coding.
# Usage: ./memorymacros mycode.bf mau-size bus-size
cat $1 > $1.tmp1
echo 'Beginning macro expansion. Initial code size:'
wc -c $1
# Following pointers
perl -pe 's/PTRGO/[NEXTCHUNK PREVCHUNK -RMOVE(CHUNK) NEXTCHUNK]/g' $1.tmp1 > $1.tmp2
@franklindyer
franklindyer / Asteroids.hs
Created September 16, 2023 00:33
Asteroids vocab game in Haskell
import System.IO
import System.Random
import System.Timeout
import System.Exit
import Control.Concurrent
import Control.Exception
import Data.Char
import Data.Maybe
import GHC.Float
@franklindyer
franklindyer / docker-installer-raspbian
Created September 19, 2023 06:30
Docker installation script on Raspbian (Up & Running book)
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/raspbian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/raspbian $(lsb_release -cs) stable" |\
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
@franklindyer
franklindyer / broken-link-crawler.js
Last active April 4, 2024 01:53
Broken link finder
@franklindyer
franklindyer / simple-repl.html
Last active December 5, 2023 23:40
Simple REPLs in HTML
<head>
<style>
div.repl {
background-color: black;
color: white;
font-family: Courier;
overflow-y: scroll;
height: 200px;
padding: 5px;
margin: 5px;
@franklindyer
franklindyer / karabiner.json
Created January 1, 2024 22:27
Karabiner complex rule for balanced delimiter mapping
// Karabiner complex ruleset for convenient balanced delimiter mapping (macOS).
// To install, follow these steps:
// 1. Install Karabiner and give it permission to capture from your keyboard in System Preferences.
// 2. Go to "complex modifications" and click on "add your own rule".
// 3. Paste the below JSON configuration into the text box that opens, and click "save".
// Here are all of the mappings that it defines:
// - Map Ctrl+9 to (), placing cursor between parens
// - Map Ctrl+[ to [], placing cursor between brackets
// - Map Ctrl+] to {}, placing cursor between parens
// - Map Ctrl+4 to $$, placing cursor between dollar signs (for LaTeX)