Skip to content

Instantly share code, notes, and snippets.

@EarlGray
EarlGray / README.md
Last active July 30, 2026 13:44
Patch rustc 1.97.1 with the "You've fallen asleep" compilation error

Patch rustc 1.97.1 with the "You've fallen asleep" compilation error

This vibecoded patch reproduces the functionality of rust-lang/rust#98551 which was built on top of rustc 1.62.0 and very regrettably was not accepted upstream.

This patch is based on the latest version of rustc as of now (Jul 30 2026), 1.97.1:

$ which ninja cmake || echo "install ninja and cmake first"
$ git clone https://github.com/rust-lang/rust.git -b 1.97.1
@EarlGray
EarlGray / Cargo.toml
Created June 9, 2025 18:04
"works on my machine" Rust -> C -> Rust `Box<dyn Any>` ffi
[package]
name = "boxany"
version = "0.1.0"
edition = "2024"
[dependencies]
[build-dependencies]
cc = "1.0"
package main
import (
"flag"
"fmt"
"io"
"log"
"os"
"os/exec"
"path/filepath"
-- This module serves as the root of the `Json` library.
-- Import modules here that should be built as part of the library.
import Std
inductive Json where
| null : Json
| bool (b: Bool)
| number (n: Int)
| array (a: List Json)
from abc import ABC, abstractmethod
from typing import Callable, Generic, Iterable, Iterator, Optional, Tuple, TypeVar, Union
T = TypeVar('T')
U = TypeVar('U')
class Functor(ABC, Generic[T]):
@abstractmethod
def fmap(self, f: Callable[[T], U]) -> 'Functor[U]':
raise NotImplemented

Parsers and DOM

  • xml-rs: roughly XML 1.0, low-level StAX-style streaming parser; no DTD validation;
  • xmlparser: very similar to xml-rs
  • quick-xml: almost zero-copy,
  • roxmltree: a read-only zero-copy "DOM" based on the source data. Not streaming? XML 1.0.
  • rxml: "alpha-quality" restricted SAX parsing of XML 1.0 with namespacing.
    • minidom builds on it, focused on xmpp
@EarlGray
EarlGray / bitbuilder.rs
Created June 20, 2023 22:10
encoding state of a Builder into a const generic bitmask
/// This is an example of encoding state of a Builder
/// into a const generic bitmask. [`PipelineBuilder`]
/// only allows `.build()` when all of the fields have
/// been set.
/// This requires a scary nightly feature that rustc
/// marks with a stark warning:
/// ```ignore
/// the feature `generic_const_exprs` is incomplete
/// and may not be safe to use and/or cause compiler crashes
@EarlGray
EarlGray / status.py
Last active July 7, 2023 22:48
dmytrish's swaybar
#!/usr/bin/env python3
"""
A swaybar implementation.
Current plugins:
- keyboard layout state and tracking
- PulseAudio-compatible sound: device, volume and mute status
- power supply: on battery/ac, percentage, time to emtpy/full
- network: the name of the primary connection, `nmmenu` on click
- time in different formats

#coding

We all know that 5 % 3 is 2 (I use % as the modulo operation sign). What about -5 % 3 or -5 % -3 in your favorite programming language?

Turns out, there are different answers.

Python

&gt;&gt;&gt; 5 % 3
#!/usr/bin/env python3
"""
This is a driver for Gravity 16x2 LCD (single-color, not RGB) for Raspberry Pi.
It is tested on Raspberry Pi Zero W with
- i2c_arm,baudrate=100000
- i2c_arm,baudrate=400000
- dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=1
"""