Skip to content

Instantly share code, notes, and snippets.

@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
@wbbradley
wbbradley / output.txt
Last active January 11, 2019 20:17
Zion Intermediate Representation Example : For Loop
tests/test_for_loop.zion:1:4: test_for_loop.main = (λ_.let __v16 = (std.iter let __range_min__v13 = 1 in let __range_next__v14 = (std.+ 1 __range_min__v13) in let __range_max__v15 = 10 in (std.Range __range_min__v13 (std.- __range_next__v14 __range_min__v13) __range_max__v15)) in (while std.True match (__v16 ()) (std.Just(x) std.print x) (std.Nothing (break!)))) :: () -> std.ExitCode
src/parser.cpp:411:1: std.+ = __builtin_add_int :: Int -> Int -> Int
src/parser.cpp:393:1: std.- = __builtin_subtract_int :: Int -> Int -> Int
tests/test_for_loop.zion:2:16: std.Range = (λ__v10.return! (λ__v11.return! (λ__v12.return! ((__v10, __v11, __v12) as! std.Range Int)))) :: Int -> Int -> Int -> std.Range Int
tests/test_for_loop.zion:2:11: std.True = ((1,) as! std.Bool) :: std.Bool
tests/test_for_loop.zion:2:11: std.iter = (λri.let index = (std.Ref (std.__get_range_min ri)) in (return! (λ_.let cur_index = (std.load_value index) in (if (std.<= cur_index (std.__get_range_max ri)) then ({__builtin_store index (std.+ cur_index
module _
type Vec has {
x float
y float
z float
}
fn main() {
var positions [int: Vec]