Skip to content

Instantly share code, notes, and snippets.

View BartMassey's full-sized avatar

Bart Massey BartMassey

View GitHub Profile
@BartMassey
BartMassey / github-unghost.sh
Last active June 4, 2024 15:11
Mark all notifications as read ("Ghost notification" remover)
#!/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
@BartMassey
BartMassey / blocksstates.py
Created March 13, 2024 03:26
Compute the number of states for an n-block Blocks World planning problem.
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
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
// 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,
@BartMassey
BartMassey / rpl.sh
Created March 15, 2022 21:50
Local "Rust Playground" script
#!/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
#!/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()
@BartMassey
BartMassey / spawn-fail.patch
Created December 8, 2021 10:07
Rust std patch to allow thread spawn to return an error rather than panicking when out of memory for an alt signal stack
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;
@BartMassey
BartMassey / crate-release-checklist.md
Created November 17, 2021 19:14
Rust Crate Release Checklist

Crate Release Checklist

First published release

  • Add Rustdoc root to the crate root

      #![doc(html_root_url = "https://docs.rs/<crate>/<version>")]
    

    (where <crate> is the crate name and <version> is the version name)

@BartMassey
BartMassey / u256conv.rs
Created January 5, 2020 07:30
Various conversions for U256 values, done properly with minimal tests
#[derive(Eq, PartialEq, Debug, Copy, Clone)]
pub struct U256([u8; 32]);
impl Into<u8> for U256 {
fn into(self) -> u8 {
for b in &self.0[0..31] {
assert_eq!(*b, 0);
}
self.0[31]
}
@BartMassey
BartMassey / tree.py
Created December 26, 2019 08:37
Prime Christmas Tree Generator
#!/usr/bin/python3
# Bart Massey
# Prime Christmas Tree printer, inspired by
# https://www.reddit.com/r/interestingasfuck/
# comments/efhy5m/i_found_this_really_great_the_correct_alignment/
# This code is licensed under the "MIT license". See
# https://opensource.org/licenses/MIT for license terms.