Skip to content

Instantly share code, notes, and snippets.

View skull-squadron's full-sized avatar
💭
*aaS unreleased project in Elixir, Rust, Typescript, Kafka, and k8s

🏴‍☠️ skull-squadron

💭
*aaS unreleased project in Elixir, Rust, Typescript, Kafka, and k8s
  • (stealth)
  • ATX
  • 19:16 (UTC -06:00)
View GitHub Profile
@skull-squadron
skull-squadron / bash-5.3-xd6.diff
Last active July 20, 2025 03:31
Bash 5.3 XDG patch
diff -ur a/bashhist.c b/bashhist.c
--- a/bashhist.c 2024-05-06 15:38:27.000000000 +0000
+++ b/bashhist.c 2025-07-20 03:02:01.549901005 +0000
@@ -419,7 +419,7 @@
char *
bash_default_histfile (void)
{
- return (bash_tilde_expand (posixly_correct ? "~/.sh_history" : "~/.bash_history", 0));
+ return find_bash_user_file(posixly_correct ? "sh_history" : "bash_history", "XDG_STATE_HOME", "~/.local/state");
}
@skull-squadron
skull-squadron / dpkg-purge-all.sh
Created July 19, 2025 11:13
Purge debian/ubuntu uninstalled packages
#!/usr/bin/env sh
exec dpkg --get-selections | awk '/deinstall$/{sub(":.*","",$1);print$1}' | xargs dpkg -P
@skull-squadron
skull-squadron / fix-go-1.21.13.diff
Last active July 17, 2025 14:07
Fix go-1.21.13 building on amd64/aarch64 on Rosetta 2
--- a/src/crypto/tls/handshake_client_test.go 2025-07-17 13:07:13.898915009 +0000
+++ b/src/crypto/tls/handshake_client_test.go 2025-07-17 12:51:59.420067002 +0000
@@ -1779,6 +1779,7 @@
test.configureClient(clientConfig, &clientCalled)
testHandshakeState := func(name string, didResume bool) {
+ t.Skip("Doesn't work on amd64 on Rosetta 2 or on QEMU")
_, hs, err := testHandshake(t, clientConfig, serverConfig)
if err != nil {
t.Fatalf("%s: handshake failed: %s", name, err)
@skull-squadron
skull-squadron / fix-go1.19.13.diff
Last active July 17, 2025 10:19
Patch to make go 1.19.13 install on amd64 on Rosetta 2
--- a/crypto/tls/handshake_client_test.go 2025-07-17 09:17:22.598688001 +0000
+++ b/crypto/tls/handshake_client_test.go 2025-07-17 09:20:10.546419009 +0000
@@ -1755,6 +1755,7 @@
t.Errorf("%s: expected server VerifyConnection called %d times, did %d times", name, wantCalled, serverCalled)
}
}
+ t.Skip("Doesn't work on amd64 on Rosetta 2 or on QEMU")
testHandshakeState(fmt.Sprintf("%s-FullHandshake", test.name), false)
testHandshakeState(fmt.Sprintf("%s-Resumption", test.name), true)
}
@skull-squadron
skull-squadron / fix-go-1.4-bootstrap.diff
Created July 17, 2025 08:48
Patch to make go 1.4 build and test on amd64 under Rosetta 2
--- a/os/exec/exec_test.go 2025-07-17 08:31:03.824802001 +0000
+++ b/os/exec/exec_test.go 2025-07-17 08:40:30.611330000 +0000
@@ -262,6 +262,7 @@
}
func closeUnexpectedFds(t *testing.T, m string) {
+ t.Skip("Doesn't work on amd64 on Rosetta 2 or on QEMU")
for fd := basefds(); fd <= 101; fd++ {
err := os.NewFile(fd, "").Close()
if err == nil {
@skull-squadron
skull-squadron / derivatives.py
Created June 30, 2025 20:51 — forked from elfsternberg/derivatives.py
Python parsing with derivatives.
#!/usr/bin/env python
# This file implements Brzozowski's parsing-with-derivatives (see:
# https://arxiv.org/abs/1604.04695) with fairly simple and
# straightforward Python code. This implementation is naive and
# subject to exponential memory growth in the worst case; in practice,
# average complexity is closer to linear. This version recalculates
# derivatives every time they are needed; memoization, the first and
# most obvious optimization, is not implemented.
#
@skull-squadron
skull-squadron / aalib.rb
Created June 23, 2025 18:19
Fixed aalib
class Aalib < Formula
desc "Portable ASCII art graphics library"
homepage "https://aa-project.sourceforge.net/aalib/"
url "https://downloads.sourceforge.net/project/aa-project/aa-lib/1.4rc5/aalib-1.4rc5.tar.gz"
sha256 "fbddda9230cf6ee2a4f5706b4b11e2190ae45f5eda1f0409dc4f99b35e0a70ee"
license "GPL-2.0-or-later"
revision 2
depends_on 'autoconf' => :build
depends_on 'automake' => :build
@skull-squadron
skull-squadron / demacl
Created June 21, 2025 17:19
remove com.apple.macl xattr
#!/bin/bash
# Free fucking beer license. It may break and you assume all responsibility.
set -eEuo pipefail
die() {
echo >&2 "$@"
exit 1
}
[[ $# = 1 ]] || die "$0 {target} <-- missing file or directory to remove all xattrs from"
@skull-squadron
skull-squadron / type_name.rs
Created May 19, 2025 20:31
Rust anything (as opposed to just `Any`) type's to string
pub trait TypeName {
fn type_name(&self) -> &str {
std::any::type_name::<Self>().trim_start_matches("dyn::")
}
}
impl<T> TypeName for T {}
#[cfg(test)]
mod tests {
@skull-squadron
skull-squadron / replace_str.rs
Last active May 20, 2025 04:30
Rust replace beginning of string generically
use std::borrow::Cow;
pub trait ReplaceBeginning<'a>: Into<Cow<'a, str>> {
fn replace_beginning(
self,
prefix: impl AsRef<str>,
replacement: impl AsRef<str>,
) -> Cow<'a, str> {
let new_self = self.into();
let prefix = prefix.as_ref();