Skip to content

Instantly share code, notes, and snippets.

@theepicsnail
theepicsnail / thing.cs
Created February 29, 2024 04:15
thing.
public class V1CurrentPlayerData
{
// a bunch of random bullshit has to happen for these to get the right values when you run the app
public static string username;
public static int points;
}
public class V1ExampleUsage
{
@theepicsnail
theepicsnail / main.rs
Created August 29, 2023 07:52
Slightly cleaned up version of the tarot/playing card to entropy bits converter.
use rand::seq::SliceRandom;
use std::io::{stdin, stdout, Write};
/// Replaces angle brackets in a format string with corresponding parameters.
///
/// This function takes a format string and a vector of parameters and replaces
/// occurrences of angle brackets with the corresponding parameter value. The format
/// string is split at angle brackets, and even indices represent parts of the string
/// outside angle brackets, while odd indices correspond to the content within angle brackets.
///
@theepicsnail
theepicsnail / main.rs
Created August 29, 2023 04:02
First pass at a CLI for querying inputs from users and outputting entropy.
// Needs cleaned up/documented. But works.
use rand::seq::SliceRandom;
use std::io::{stdin, stdout, Write};
/* This program will convert a shuffled deck into a binary entropy string. */
/*
More or less format!, but accepts:
non-compile-time format strings
vec<str> params
@theepicsnail
theepicsnail / main.rs
Last active August 24, 2023 09:38
Tool for converting a playing card or tarot card deck into an entropy string.
/* This program will convert a shuffled deck into a binary entropy string. */
/*
Big-int MAC/MAD function.
https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation
We're storing unsigned monotonic numbers in base 256 using a Vec<u8>.
We never multiply or add more than a single u8 at a time, so this lets us do linear-time MAC operations.
This will resize the bigint as necessary.
@theepicsnail
theepicsnail / deckToWords.py
Created August 23, 2023 06:02
deckToWords.py
# Notes: This does not generate a valid seed.
# Theres a handful of endianness problems.
# This does not compute checksums
# This is a proof of concept for converting a permutation into a base 2048 number.
# With a few more tweaks and some precise memory management, it should be compatable with proper bep-39 tools.
from math import perm, log
DECK_52 = [face+suit for suit in "HCDS" for face in "A234567890JQK"]
"""Math behind entropy of shuffled decks and card pulling strategies.
This file contains 3 parts:
1) Helper methods intended to make the rest of the code more human readable.
2) An exploration on the math behind different deck sizes and usage strategies.
3) A conclusion at the bottom with my personal opinion on the topic.
Some assumptions for this to hold:
An end user can shuffle a deck of cards into a random state.
Note: this is more complicated than 7 riffle shuffles. http://frans.us/research/pubs/NewAgeS.pdf?i=1
>>> d = defaultdict(int)
>>> for i in range(100000):
... d[len(set(random.randint(0,2047) for i in range(24)))] += 1
...
>>> print(d)
defaultdict(<class 'int'>, {24: 87462, 23: 11775, 22: 739, 21: 23, 20: 1})
87,472
100,000
#include <Ethernet.h>
#define rfTransmitPin 4
#define timeDelay 105
#define BEEP 0
#define VIBRATE 1
#define SHOCK 2
/* RF stuff */
#define LONG_PULSE 1260
#define SHORT_PULSE 315
Blend[_SrcBlend][_DstBlend]
BlendOp [_BlendOp]
Cull [_CullMode]
ZWrite [_ZWrite]
Stencil {
Ref [_Ref]
ReadMask [_ReadMask]
WriteMask [_WriteMask]
Comp [_Comp]
bazel build @com_github_tommyulfsparre_aurora_exporter//:com_github_tommyulfsparre_aurora_exporter