Skip to content

Instantly share code, notes, and snippets.

View DougAnderson444's full-sized avatar
🕸️
Open Web, all the way

Doug A DougAnderson444

🕸️
Open Web, all the way
View GitHub Profile
@DougAnderson444
DougAnderson444 / RustFlex.md
Created March 11, 2025 11:49
Flexible Rust Options

Trait objects

Use trait objects (&dyn Fn()) when you need runtime polymorphism and don't mind the small performance cost of dynamic dispatch.

Generics

Use generics (F: Fn()) for better performance through static dispatch, but at the cost of potential code bloat due to monomorphization.

Smart Pointer

@DougAnderson444
DougAnderson444 / Cargo.toml
Created February 26, 2025 20:09
WIT Bindgen add derive attrs
# It's not documented, but you can use `package.metadata.component.bindings` to
# set additional derive attributes for the generated bindings:
[package.metadata.component.bindings]
derives = ["serde::Serialize", "serde::Deserialize", "Hash"]
@DougAnderson444
DougAnderson444 / beetswap-webrtc-woes.md
Last active February 21, 2025 23:23
So you want to use Beetswap + WebRTC? Read this first.

Beetswap in the Browser

Beetswap uses libp2p-core v0.42.0

Which means that any time you want to use Beetswap, you'll need core v0.42.0.

Oh, you want to use WebRTC though? That's fine.

Well, you'll need libp2p-webrtc-websys version 0.4.0 because anything before that breaks because __Nonexhaustive was switched to __Invalid in wasm-bindgen.

@DougAnderson444
DougAnderson444 / new_web.md
Created October 30, 2024 01:04
New Way To Browse?

A New Web?

So there's the web browser which everyone has, but JavaScript is slow and insecure.

But there's a bunch of tech out there that doesn't really need JavaScript; Rust => WebAssembly. So why are we bending over backwards to fit things into the browser?

What if we had a modular way to share "sites" that were really wasm apps. We could use 1 "wasm browser" and just run these apps.

If these wasm apps output a display to egui, we could load these wasm apps as plugins and just run the thing. Can we load a WIT component into egui and have it output the right display? If so, it's so on.

@DougAnderson444
DougAnderson444 / auto_traits.rs
Created October 16, 2024 14:00
auto-trait test / autotrait hack
// ensures you get compiler warnings if your type suddenly (unexpectantly) break autotraits
// from Rust for Rustaceans Book
mod tests {
use ipns_entry::entry::IpnsEntry;
fn is_normal<T: Sized + Send + Sync + Unpin>() {}
#[test]
@DougAnderson444
DougAnderson444 / github-workflows-rust.yml
Last active March 2, 2025 17:46
Github Action to build & deploy Leptos Website
name: Build Rust & Deploy Leptos Page
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
@DougAnderson444
DougAnderson444 / chadrd.lua
Created October 6, 2023 23:44
Initial ChadRC File
local M = {}
M.plugins = "custom.plugins"
-- key mapping file
M.mappings = require "custom.mappings"
-- set our custom plugins.lua file here
M.ui = {
theme = "chadracula",
@DougAnderson444
DougAnderson444 / hd-wallet.md
Created August 11, 2023 15:55
Hierarchical Deterministic Wallets - Hardened versus Non-hardened Keys

Hardened vs Non-hardened

With non-hardened keys, one can derive child public keys of a given non-hardened parent key without knowing any private key.

You cannot do this with hardened keys.

Non-Hardened Security Risks

Knowledge of a parent extended public key plus any non-hardened private key descending from it is equivalent to knowing the parent extended private key (and thus every private and public key descending from it).

@DougAnderson444
DougAnderson444 / VouchedDiscovery.md
Last active August 2, 2023 01:02
Vouched Discovery

So let's say I want to find someone in Web3 by some contact information I have about them.

  • Phone number
  • Email address
  • Physical address
  • First name

...whatever.

Let's assume there's a network where anyone can save this sort of information, like IPFS / libp2p.

// relevant issue:
https://github.com/sveltejs/kit/issues/2040
npm i typescript-transform-extensions ts-patch -D
// tsconfig.json
"plugins": [
{
"transform": "typescript-transform-extensions",
"extensions": {