Skip to content

Instantly share code, notes, and snippets.

@wbbradley
wbbradley / README.md
Last active February 17, 2026 20:31
Guide to getting started
@wbbradley
wbbradley / panic-thread.rs
Created February 7, 2025 15:30
Example of panic! inside a thread in Rust
fn main() {
let x = std::thread::spawn(|| {
std::thread::sleep(std::time::Duration::from_secs(1));
panic!("I am crashing!");
})
.join();
println!("This result should not be visible! {x:?}");
}
/// This program's output:
@wbbradley
wbbradley / init.lua
Created October 22, 2024 22:17
Snippet of destructuring clipboard in neovim Lua to find lines to populate the location list window.
local function nmap(shortcut, command)
keymap("n", shortcut, command)
end
nmap("<leader>P", ":PopulateQuickFixFromClipboard<CR>")
vim.api.nvim_create_user_command("PopulateQuickFixFromClipboard", function()
-- Grab the contents of the system clipboard
local clipboard_contents = vim.fn.system("pbpaste")
local clipboard_lines = vim.split(clipboard_contents, "\n", { plain = true, trimempty = true })
@wbbradley
wbbradley / README.md
Last active October 30, 2021 23:05
bootstrappy

bootstrappy

A bash script that will bootstrap any Python script.

Requirements

  • Uses Python3
  • The command is installed with the same package name as how it is invoked. For example: pip install cmakelint allows you to run cmakelint

Usage:

#include <iostream>
#include <map>
#include <memory>
struct X {
X(int x) : x(x) {}
int x;
};
typedef std::multimap<int, std::shared_ptr<X>> Map;

two_functions.zion

let c = |f, g| => |x| => f(g(x))
fn d(f, g) {
  return fn (x) {
    return f(g(x))
  }
}
/*
https://projecteuler.net/problem=19
1 Jan 1900 was a Monday.
Thirty days has September,
April, June and November.
All the rest have thirty-one,
Saving February alone,
Which has twenty-eight, rain or shine.
And on leap years, twenty-nine.
/**********************************************************************************************
*
* raylib 32x32 game/demo competition
*
* Competition consist in developing a videogame in a 32x32 pixels screen size.
*
* LICENSE: zlib/libpng
*
* Copyright (c) 2020 Will Bradley (@wbbradley)
*
function column-sum() {
column=$1
delim=${2:-','}
awk -F "$delim" '
BEGIN { sum=0 }
{ sum += $'"$column"' }
END { print sum }
'
}
function column-only-above() {
@wbbradley
wbbradley / compo.c
Created April 14, 2020 23:02 — forked from chriscamacho/compo.c
Raylib 32x32 competition template
/**********************************************************************************************
*
* raylib 32x32 game/demo competition
*
* Competition consist in developing a videogame in a 32x32 pixels screen size.
*
* RULES:
*
* 1) Use only raylib (and included libraries), no external libraries allowed
* 2) The submission should consist of just one source file