Skip to content

Instantly share code, notes, and snippets.

View mbutler's full-sized avatar
🇦🇶
Exploring

Matthew Butler mbutler

🇦🇶
Exploring
View GitHub Profile
@mbutler
mbutler / dicepools.py
Last active February 5, 2024 22:24
working with dice pools
import random
import collections
def roll_dice(dice):
"""Rolls mixed dice and returns the sum.
- dice: List of tuples (die_size, quantity) for each die type."""
total = 0
for die_size, quantity in dice:
for _ in range(quantity):
total += random.randint(1, die_size)
@mbutler
mbutler / gaslands
Last active January 21, 2024 22:00
Round structure for Gaslands: Refueled
### Gaslands Round Structure:
#### Gear Phases:
- Each round is divided into **6 Gear Phases** (from 1 to 6).
- A vehicle qualifies for activation in a Gear Phase if its **current Gear is equal to or higher** than the Gear Phase number and it has not yet activated in that Gear Phase.
- Starting with the player in **Pole Position**, players take turns activating a single qualifying vehicle. The **Pole Position** marker is passed clockwise to the next player at the end of each Gear Phase.
#### Vehicle Activation:
1. **Movement Step**:
- **Select a movement template**: Choose a permitted template based on the vehicle's current Gear.
@mbutler
mbutler / fsk.py
Created January 20, 2024 19:36
Simple Frequency Shift Keying implementation for digital modulation
import numpy as np
import wave
import struct
from scipy.signal import butter, lfilter
# Function to convert text to FSK and save as a WAV file
def text_to_fsk_wave(text, filename):
bit_rate = 1200
freq_low = 1200
freq_high = 2400
@mbutler
mbutler / painting-prompt.md
Created January 20, 2024 18:03
Prompt DALL-E for a style of painting that I like

"Create a painting using traditional oil painting techniques on canvas. Begin with a toned ground to establish a neutral mid-tone. Sketch out the composition with an underpainting, focusing on correct values. Build up the painting with multiple layers of both opaque and translucent oil paints, employing a variety of brushwork: fine, detailed strokes for texture and broader gestures for the background. Use glazing techniques to enrich colors, starting with lighter hues and gradually adding darker shades to create depth. Maintain a controlled palette of earth tones with strategic touches of high chroma colors for visual accents. Pay attention to edge quality, keeping them sharp in the foreground and softer in the background. Finish with a varnish to enhance the vibrancy and depth of colors."

@mbutler
mbutler / base64-steganography.js
Last active January 14, 2024 20:22
steganography in base64 images
const PNG = require('pngjs').PNG
const fs = require('fs')
// Function to embed text into a base64 encoded PNG
function embedTextInBase64PNG(base64Image, text) {
let data = Buffer.from(base64Image, 'base64')
let png = PNG.sync.read(data)
let textBinary = (text + '\0').split('').map(char => char.charCodeAt(0).toString(2).padStart(8, '0')).join('')
let dataIndex = 0
@mbutler
mbutler / comic-prompt.md
Last active January 15, 2024 01:12
dall-e prompt template

A fully colored hand-drawn comic illustration in the style of 1960s pulp adventure magazines, without any textual elements. The coloring should use muted washes, with a palette that is vibrant yet subdued, typical of 60s comic illustrations, capturing the textured, ink-heavy look with dramatic shading and expressive line work.

The scene is [describe the specific scene or setting]

In the foreground, [describe the main character or characters, including appearance and actions].

[Include any additional background elements or details].

=====================

@mbutler
mbutler / pyxel-nn.py
Created January 3, 2024 21:15
a rudimentary neural network for the Pyxel coding pet
from pyxel import Pyxel
pyxel = Pyxel()
class random_for_pyxel:
def __init__(self, seed=1):
self.a = 1664525 # Multiplier
self.c = 1013904223 # Increment
self.m = 2**32 # Modulus
self.seed = seed
@mbutler
mbutler / pyxelAPI.md
Created January 3, 2024 20:48
Pyxel robot dog python commands
Command Description Example Usage
Backward Moves a user defined distance backward. pyxel.Backward(6,0,0)
Chase Tail Chases wagging tail in a circle a user defined direction. pyxel.ChaseTail(1)
Dance PYXEL shows off its dance moves. pyxel.Dance()
Delay Code pauses for a user defined amount of time. pyxel.Wait(1)
Eyes User defines PYXEL's emotion for one or both eyes.
@mbutler
mbutler / santas_cookies.md
Created December 23, 2023 19:46
Santa's Official Cookie. The official Christmas cookie of the North Pole

Ingredients

Cookies

  • 2 and 1/4 cups (281g) all-purpose flour (spooned and leveled), plus more as needed for rolling and work surface
  • 1/2 teaspoon baking powder
  • 1/4 teaspoon salt
  • 3/4 cup (12 Tbsp; 170g) unsalted butter, softened to room temperature
  • 3/4 cup (150g) granulated sugar
  • 1 large egg, at room temperature
  • 2 teaspoons pure vanilla extract
@mbutler
mbutler / maxattribute.py
Created December 23, 2023 16:07
generate 10 million D&D character attribute sets and report the highests
import random
def roll_4d6_drop_lowest():
"""Roll 4d6 and return the sum of the highest three rolls."""
rolls = [random.randint(1, 6) for _ in range(4)]
return sum(sorted(rolls)[1:]) # Sum the three highest rolls
def generate_character_stats():
"""Generate a set of 6 character stats."""
return [roll_4d6_drop_lowest() for _ in range(6)]