Skip to content

Instantly share code, notes, and snippets.

View Taywee's full-sized avatar

Taylor C. Richberger Taywee

View GitHub Profile
@Taywee
Taywee / montyhall.py
Created February 26, 2024 18:42
Monty Hall Problems
import random
from enum import Enum, auto, unique
@unique
class Prize(Enum):
CAR = auto()
GOAT = auto()
results = {
Prize.CAR: 0,
@Taywee
Taywee / alltoz64.py
Created February 20, 2019 20:30
Simple python converter to change an input n64 rom to z64 format from any other byte order format
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright © 2019 Taylor C. Richberger <taywee@gmx.com>
# This code is released under the MIT license
import argparse
import shutil
from io import BytesIO
def convertchunk(chunk, byteswapped, wordswapped):
@Taywee
Taywee / 348h.rs
Created February 4, 2018 07:23
Implementation of daily programming challenge 348 Hard. Reimplementation of existing algorithm, but in Rust.
use std::env;
#[derive(Debug, Clone, Copy)]
struct Pair(u32, u32);
impl Pair {
fn contains(&self, item: u32) -> bool {
self.0 == item || self.1 == item
}
// Get the item that isn't the one passed in
@Taywee
Taywee / enumerator.rb
Last active August 21, 2022 19:34
Ruby enumerator/enumerable implementations, minus lazy
# FOR TESTING, REMOVE FOR ACTUAL USE
Object.send(:remove_const, :Enumerator)
Object.send(:remove_const, :Enumerable)
module Enumerable
# Used for undefined arguments, because "nil" can be significant.
UNDEFINED = BasicObject.new
def all?
return all? {|obj| obj} unless block_given?
@Taywee
Taywee / encounters.py
Created August 18, 2018 06:27
Simple MIT-licensed Dungeons and Dragons encounter calculator written in python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright © 2018 Taylor C. Richberger <taywee@gmx.com>
# This code is released under the MIT license
import locale
import argparse
from collections import namedtuple
Threshold = namedtuple('Threshold', ['easy', 'medium', 'hard', 'deadly'])
@Taywee
Taywee / dirfs.cxx
Created October 29, 2018 18:52
Simple sloppy directory-based sqlite VFS. MIT License
/* Copyright © 2018 Taylor C. Richberger <taywee@gmx.com>
* This code is released under the MIT license
*/
#include <memory>
#include <iostream>
#include <iterator>
#include <sstream>
#include <fstream>
#include <vector>
@Taywee
Taywee / dp370e.rs
Created December 19, 2018 05:50
Daily Programmer 370 Easy first shot solution.
// Given a slice of upc digits, return the checksum
fn upc_raw(input: &[u8]) -> u8 {
let mut code = Vec::from(input);
while code.len() < 11 {
code.insert(0, 0);
}
if code.len() > 11 {
code.resize(11, 0);
}
@Taywee
Taywee / rogers.py
Created August 27, 2019 05:22
Convert hexadecimal numbers to the S. R. Rogers pronunciation system (MIT License)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright © 2019 Taylor C. Richberger
# This code is released under the MIT license
import argparse
base = {
'0': 'zero',
'1': 'one',
@Taywee
Taywee / hanoi-backups.py
Last active April 6, 2021 17:33
Simple commented example of a very simple hanoi backup rotation function, released MIT
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright © 2016 Taylor C. Richberger <taywee@gmx.com>
# This code is released under MIT license
import locale
import argparse
import string
def hanoi(day, tapes):
@Taywee
Taywee / kh.js
Last active December 4, 2018 07:54
kathack https
/*
Copyright Alex Leone, David Nufer, David Truong, 2011-03-11. kathack.com
javascript:var i,s,ss=['http://kathack.com/js/kh.js','http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'];for(i=0;i!=ss.length;i++){s=document.createElement('script');s.src=ss[i];document.body.appendChild(s);}void(0);
*/
var BORDER_STYLE = "1px solid #bbb",
CSS_TRANSFORM = null,
CSS_TRANSFORM_ORIGIN = null,
POSSIBLE_TRANSFORM_PREFIXES = ['-webkit-', '-moz-', '-o-', '-ms-', ''],