Skip to content

Instantly share code, notes, and snippets.

View bb010g's full-sized avatar
💭
questionable ideas, made with 💛

bb010g bb010g

💭
questionable ideas, made with 💛
View GitHub Profile
@bb010g
bb010g / withInterval.js
Created October 14, 2022 02:18
JavaScript/TypeScript `withInterval`
export class IntervalCancelledError extends Error {
constructor(intervalCount, ...args) {
super(...args);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, IntervalCancelledError);
}
this.name = "IntervalCancelledError";
this.intervalCount = intervalCount;
}
}
@bb010g
bb010g / 100-test-shells.zsh
Last active October 5, 2021 13:36
"POSIX-compatible" shell comparsion
#!/usr/bin/env zsh
emulate -R zsh
autoload -Uz zmathfunc; zmathfunc
# zmodload -F zsh/mathfunc
unset ENV
unset BASH_ENV
case $NIXPKGS in '') NIXPKGS="nixpkgs/ee084c02040e864eeeb4cf4f8538d92f7c675671";; esac
@bb010g
bb010g / 500-mrsh-last_status-trace-internal.txt
Created October 5, 2021 00:42
mrsh `state->last_status` test, tracing internal execution
bb010g ~/.../c/mrsh % ./build/mrsh -c 'true; foo="`true``false`$? `printf "%s\n" "$?"``false`"; printf "%s\n" "$? $foo"' 2>&1
main (post mrsh_parse_line): program
├─command_list ─ pipeline
│ └─simple_command
│ └─name ─ word_string [1:1 → 1:5] true
├─command_list ─ pipeline
│ └─simple_command
│ └─assignment
│ ├─name foo
│ └─value ─ word_list (quoted)
@bb010g
bb010g / ring-buffer.ts
Created October 16, 2020 04:31
TypeScript power-of-two ring buffer (circular buffer)
// Copyright 2020 Dusk <me@bb010g.com>
// SPDX-License-Identifier: 0BSD
class RingBuffer<T> {
buffer: T[];
readIx: number;
writeIx: number;
ixMask: number;
canGrow: boolean;
canDrop: boolean;
@bb010g
bb010g / + Python dev env with Nixpkgs.md
Last active April 18, 2024 02:50
Example Python development environment with Nixpkgs

Example Python development environment with Nixpkgs

This project requires Python 3.6.

This project isn't packaged, and traditionally uses:

$ python -m venv venv
$ source venv/bin/activate
$ pip install "${pypi_deps[@]}"
@bb010g
bb010g / X-Moto-PSP-0.2.patch
Created July 20, 2020 08:20
X-Moto 0.4.2 PSP
diff --git a/changes.txt b/changes.txt
new file mode 100644
index 0000000..3aba1b5
--- /dev/null
+++ b/changes.txt
@@ -0,0 +1,9 @@
+Change log file for X-Moto-PSP
+
+version 0.2 (2008-12-28)
+ * fix compilation with latest SDK
@bb010g
bb010g / xmoto-0.5.10-src-amiga.patch
Created July 20, 2020 07:15
X-Moto 0.5.10 AmigaOS4
diff -Naur xmoto-0.5.10/configure xmoto-0.5.10-new/configure
--- xmoto-0.5.10/configure 2012-05-04 05:07:06
+++ xmoto-0.5.10-new/configure 2012-06-23 05:19:03
@@ -5974,7 +5974,7 @@
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
-LIBS="-lGLU $LIBS"
+LIBS="-lGL -lGLU $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@bb010g
bb010g / recursion-schemes.nix
Created May 30, 2020 03:56
bad Nix recursion schemes draft
{ lib, libSuper }:
let
# lib imports {{{1
inherit (lib.trivial) #{{{2
comp
flow
;
inherit (lib.recursionSchemes) #{{{1
# vMu- vMu_ v-Mu v_Mu # (mod)
@bb010g
bb010g / 100-retro-forth-mirror.sh
Last active August 25, 2020 22:25
RETRO Forth mirror script
#!/usr/bin/env dash
set -eu
## print argument, but shell quoted
quote() { #{{{1
local arg; for arg; do
alias __quote_tmp_alias_arg="$arg"
arg="$(alias __quote_tmp_alias_arg)"
arg="${arg##*__quote_tmp_alias_arg=}"
printf '%s\n' "$arg"
@bb010g
bb010g / extract-library-resource.cs
Created February 9, 2020 04:31
Extract Windows library resources
using System;
using System.Collections.Generic;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
namespace ExtractLibraryResource