Skip to content

Instantly share code, notes, and snippets.

View kazcw's full-sized avatar

Kaz Wesley kazcw

  • Freelance
  • Seattle, WA
View GitHub Profile
@kazcw
kazcw / pi4-stepping.sh
Last active November 8, 2021 18:11
distinguish Raspberry Pi 4 steppings
#!/bin/sh
# Distinguishes B0 from C0. Likely won't distinguish C0 from whatever comes next.
SD=$(od -An -tx1 -w24 /proc/device-tree/emmc2bus/dma-ranges | tr -d ' ')
if [ $SD = 00000000c0000000000000000000000040000000 ]; then echo B0; exit; fi
if [ $SD = 00000000000000000000000000000000fc000000 ]; then echo C0; exit; fi
echo '??'
@kazcw
kazcw / reliability-vs-ub.md
Last active November 16, 2018 22:38
proposed policy on reachable UB in Bitcoin Core

Classification of undefined behavior that is not demonstrably unreachable in production:

Unportable (across toolchains as well as platforms)

Classes of "technically undefined" behavior that a lot of software depends on, so the supported toolchain/platform combinations wouldn't be able to get away with breaking it.

Examples: Out-of-bounds pointer created, but not dereferenced

@kazcw
kazcw / rustc-local.nix
Created November 9, 2018 19:26
nix script to build rustc from local source
stdenv.mkDerivation {
name = "rustc-local";
buildInputs = [
gcc gnumake python2 cmake curl git
# if enabled in config.toml
ninja
];
}
@kazcw
kazcw / esy.nix
Last active February 27, 2020 16:12
run esy under NixOS
{ pkgs ? import <nixpkgs> {} }:
(pkgs.buildFHSUserEnv {
name = "esy-env";
targetPkgs = pkgs: (with pkgs;
[
# this set suffices to build esy 0.3.4 with esy 0.2.11
# and also to build the hello-ocaml demo with esy 0.3.4
nodejs-10_x
stdenv.cc
@kazcw
kazcw / Cargo.toml
Created August 19, 2016 19:09 — forked from gkbrk/Cargo.toml
Asynchronous server example in Rust
[package]
name = "rust-async-qotd"
version = "0.1.0"
authors = ["Gökberk Yaltıraklı <webdosusb@gmail.com>"]
[dependencies]
tokio = { git = "https://github.com/tokio-rs/tokio" }
rand = "0.3"
@kazcw
kazcw / sparseblocks.md
Last active August 29, 2015 14:04
Squashing redundant tx data in blocks on the wire

Sparse blocks

  • exchange priority policies in peer introductions
  • assign unique sequential IDs in the order the transactions were inved (per peer) receiving a getdata for a tx updates last-known-peer-received inv to all invs up to the one referenced
  • include ID-last-received, last-known-peer-received in sparse block
  • reference txes in sparse block by index in receiver's prioritiziation with peer's sent invs up to ID-last-received and sender's prior invs up to last-known-peer-received