This file contains hidden or 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
# Implementations from Wikipedia | |
# https://en.wikipedia.org/wiki/Thue%E2%80%93Morse_sequence | |
from math import ceil, log2 | |
from sys import argv | |
def thue_morse_fast(n): | |
def generate_sequence(seq_length): | |
"""Thue–Morse sequence.""" | |
value = 1 |
This file contains hidden or 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
//! # [*Advent of Rust 2024* Day 4]: Kids and Niceness | |
//! Bart Massey 2024 | |
//! | |
//! This code is licensed under the "MIT License". License terms | |
//! are [here](https://opensource.org/license/mit). | |
//! | |
//! This code is a demo of how to solve the given problem with reasonable | |
//! programming style and correctness, | |
//! | |
//! [*Advent of Rust 2024* Day 4]: https://www.rustfinity.com/practice/rust/challenges/aor-2024-4 |
This file contains hidden or 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
struct V([u64; 3]); | |
impl std::ops::Deref for V { | |
type Target = [u64; 3]; | |
fn deref(&self) -> &Self::Target { | |
&self.0 | |
} | |
} | |
impl<'a> IntoIterator for &'a V { |
This file contains hidden or 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
#!/bin/sh | |
# Mark all notifications as read, including "ghost" notifications. | |
# Works on Linux, requires a "classic" auth token be present in `~/.github-oauthtoken` | |
# and also that `gh` is installed. You could presumably use `gh auth login` instead | |
# if you want to authenticate that way. | |
# | |
# Works for me, use at your own risk. | |
# | |
# https://github.com/orgs/community/discussions/6874 | |
# https://docs.github.com/en/rest/activity/notifications?apiVersion=2022-11-28#mark-notifications-as-read |
This file contains hidden or 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 math, sys | |
# Number of blocks to manipulate | |
nblocks = int(sys.argv[1]) | |
# Number of ways to order a stack of nstack blocks. | |
def orderings(nstack): | |
return math.factorial(nstack) | |
# Generate all partitions of nblocks. A partition of nblocks |
This file contains hidden or 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 numpy as np | |
import scipy.signal as ss | |
tau = 2 * np.pi | |
# Filter coefficients from | |
# | |
# cs = ss.iirfilter(1, (990, 1010), btype='bandpass', output='sos', fs=48000) | |
# | |
# Filter coefficient order is b0, b1, b2, a0, a1, a0. Filter |
This file contains hidden or 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
// egui hello world example, modified per | |
// https://www.reddit.com/r/learnrust/comments/v64f0q/egui_label_not_appearing/ | |
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] | |
use csv::{self}; | |
use eframe::egui; | |
struct MyApp { | |
filename: String, |
This file contains hidden or 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
#!/bin/sh | |
# Local "Rust Playground" | |
# Bart Massey 2021 | |
# Requires `cargo-add` and this additional shell function: | |
# function rpl { | |
# DIR="`$HOME/bin/mi/rpl \"$@\"`" && | |
# echo "dir '$DIR'" >&2 && | |
# pushd $DIR && | |
# if [ -f src/main.rs ] | |
# then |
This file contains hidden or 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/python3 | |
# Transform text to one-sentence-per-line format. | |
# Bart Massey 2021-01-20 | |
import re, sys | |
blank = re.compile("^[ \t]*$") | |
dot = re.compile("[.] ") | |
text = open(sys.argv[1], "r").read().splitlines() |
This file contains hidden or 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
diff --git a/library/std/src/sys/unix/stack_overflow.rs b/library/std/src/sys/unix/stack_overflow.rs | |
index 1e8d1137ac8..eade97af5c6 100644 | |
--- a/library/std/src/sys/unix/stack_overflow.rs | |
+++ b/library/std/src/sys/unix/stack_overflow.rs | |
@@ -1,28 +1,26 @@ | |
#![cfg_attr(test, allow(dead_code))] | |
-use self::imp::{drop_handler, make_handler}; | |
+use crate::io; | |
NewerOlder