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
Copyright 2025 ItsDrike <[email protected]> | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTW |
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
pub mod parser; | |
pub mod ranges; | |
use parser::{Input, RemapRule}; | |
use crate::ranges::apply_ruleset_remaps; | |
impl RemapRule { | |
pub fn remap(&self, num: u64) -> u64 { | |
let src_range = self.source_range(); |
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
use std::collections::{HashMap, HashSet}; | |
#[derive(Debug)] | |
enum Ast { | |
Const(f64), | |
Var(u32), | |
Add(Box<Ast>, Box<Ast>), | |
Assign(u32, Box<Ast>), | |
Print(Box<Ast>), | |
Block(Vec<Ast>), |
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
# Example GIF: https://user-images.githubusercontent.com/20902250/174349934-7a241462-93da-4376-8fac-71d83048f5bf.gif | |
# NOTE: This is a re-upload of a program I made several years ago. | |
import math | |
import time | |
import typing as t | |
from queue import PriorityQueue | |
import pygame |
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/python | |
# Linear Feedback Shift Register (LFSR) Random Number generator We should be | |
# able to go through all of the possible states from our initial one before we | |
# start repeating. This means that we can have 2^n-1 unique numbers, n being | |
# the number of bits in our state before we start repeating numbers. | |
# Warning: This algorithm is NOT cryptographically secure, because given enough | |
# outputted bytes, by solving a bunch of linear equations and recompute the | |
# LFSR generator bits. If we do need something cryptographically secure, we |
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 __future__ import annotations | |
from typing import cast, Callable | |
from functools import wraps | |
_MISSING = object() # Sentinel value to avoid conflicts with vars set to None | |
class AutoCacheMeta(type): | |
def __new__(cls: type[AutoCacheMeta], name: str, bases: tuple[type[object]], clsdict: dict[str, object], **kwargs): | |
allow_missing_cache = kwargs.pop("allow_missing_cache", False) |
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 inspect | |
from typing import Hashable, Any, Optional, Callable, TypeVar | |
# Make a unique object for unambiguously distinguishing some missing values. | |
# (Simply using None wouldn't work, because the actual value could have been None) | |
_MISSING = object() | |
# Define a callable type var for the @overload decorator function, to satisfy |
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
import io | |
from contextlib import redirect_stdout | |
import random | |
import secrets | |
import decimal | |
from decimal import Decimal, InvalidOperation, getcontext | |
# Set decimal precision high enough to compute the interpolation | |
# without any loss in floating point operations | |
getcontext().prec = 500 |
This file has been truncated, but you can view the full file.
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
import base64 | |
c = "CmltcG9ydCBiYXNlNjQKCmMgPSAiQ21sdGNHOXlkQ0JpWVhObE5qUUtDbU1nUFNBaVEyMXNkR05IT1hsa1EwSnBXVmhPYkU1cVVVdERiVTFuVUZOQmFWRXlNWE5rUjA1SVQxaHNhMUV3U25CWFZtaFBZa1UxY1ZWVmRFUmlWVEZ1VlVaT1FtRldSWGxOV0U1clVqQTFTVlF4YUhOaE1VVjNVMjVDV0ZadGFGQlphMVV4WTFaV1ZtUkZVbWxXVkVaMVZsVmFUMUZ0UmxkU1dHeE9WMFUxY2xWcVFURlRWbEY0WVVoT2FFMVZWak5WTWpWRFYwWmFkR0ZHUWxwaE1WVjRXVEZhVjFadFVrWlZiV3hYVmtWYU1WWnNWbUZVTVVaMFVteGtVMWRIZUU5V01GVXhZMnhXY1ZGVVJsUldiRVkwV1ZWb1QyRkZNVlpXYWs1V1RXcFdSRll3V21Ga1IwWkhVV3h3YUUxV1ZqUlhWRVpoVmpGYWRGVnJXbFppVjNoWVZtdFdZVTFXV25OV2JVWlZUVlZhTUZWdGVHdFZNV1JJWlVVNVYwMUdWWGhaTW5oWFkxWkdWVkpzVWxkaVJWa3dWMVpXYjFReVJrWk5WbHBYWVdzMVYxUlhjRmRTUmxsM1YyMUdhMUl3V2toVlYzaDNZVVV4VjFacVVsaFdSVnBvVm1wR1lXUkdWbkpYYkZwcFZqTm9XVlp0ZEZkWlZURlhWMjVPVjJKVldsWlVWbFpoVFVaV2RHVkhkRlpOVjFKSldsVlZOVll3TVVkV1dHaGFUVzVvV0ZreFdrZFdWa3B6Vld4a2FWSldhM2RXTVZwWFlqRlJlVkpyV2s1V2JIQllXVmR6TVZZeFVsaGpSbVJUVW14c00xWXlNVWRoTVVsM1YydG9WbFl6YUROWlZWVjRWakZhY1ZWc2FGZFNWbkJ2Vm0xd1IxbFhVa2RXYmtwWVlrWndjRlpxVG05WFZscDBaRVprV2xaVVJsaFdNalZ |
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
""" | |
This attempts to abstarct away the standard way of using `__init__`, | |
the problem it tries to solve is the repetetiveness of using init purely | |
to store it's parameters into the instance under the exactly same name, i.e.: | |
class Stock: | |
def __init__(name, shares, price): | |
self.name = name | |
self.shares = shares | |
self.price = price | |
""" |
NewerOlder