Skip to content

Instantly share code, notes, and snippets.

@saolsen
saolsen / Dockerfile
Created April 16, 2024 14:03
Deno On Fly
ARG DENO_VERSION=1.42.2
ARG BIN_IMAGE=denoland/deno:bin-${DENO_VERSION}
FROM ${BIN_IMAGE} AS bin
FROM frolvlad/alpine-glibc:alpine-3.13
RUN apk --no-cache add ca-certificates
RUN addgroup --gid 1000 deno \
&& adduser --uid 1000 --disabled-password deno --ingroup deno \
@saolsen
saolsen / .Rust_Vals.md
Last active December 26, 2023 00:29
Rust Val

Make a Val with rust.

Build a https://www.val.town/ val with rust. This is an example of how to compile a rust file to wasm and use it as a val.

Requires rust, wasm-pack and deno.

Usage

  • Put your code in val.rs.
  • Build it.
@saolsen
saolsen / day13_part1.py
Last active October 25, 2023 17:35
aoc 2022 day13
from itertools import batched
def ordered(a, b) -> bool | None:
match a, b:
case int(i), int(j):
if i == j:
return None
return i < j
case list(i), list(j):
@saolsen
saolsen / copy_tmux_output.md
Created July 13, 2023 18:23
Copy tmux output
@saolsen
saolsen / .gitignore
Last active July 13, 2023 18:00
rust flat directory, whole rust project in a gist
target
@saolsen
saolsen / main.rs
Created July 11, 2023 19:20
connect4 monte-carlo tree search with rayon
use rayon::prelude::*;
use thiserror::Error;
const ROWS: usize = 6;
const COLS: usize = 7;
#[derive(Debug)]
pub struct Connect4Action {
pub column: usize,
}
@saolsen
saolsen / Dockerfile
Last active May 11, 2023 18:47
connect4_mcts
FROM debian:stable-slim as get
WORKDIR /bun
RUN apt-get update
RUN apt-get install curl unzip -y
RUN curl --fail --location --progress-bar --output "/bun/bun.zip" "https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip"
RUN unzip -d /bun -q -o "/bun/bun.zip"
RUN mv /bun/bun-linux-x64/bun /usr/local/bin/bun
RUN chmod 777 /usr/local/bin/bun
@saolsen
saolsen / lldb.log
Created December 28, 2022 15:48
lldb.log
ProcessGDBRemote::StartAsyncThread ()
< 1> send packet: +
ProcessGDBRemote::AsyncThread (arg = 0x1498a7018, pid = 0) thread starting...
ProcessGDBRemote::AsyncThread (arg = 0x1498a7018, pid = 0) listener.WaitForEvent (NULL, event_sp)...
history[1] tid=0x0103 < 1> send packet: +
< 19> send packet: $QStartNoAckMode#b0
< 1> read packet: +
< 6> read packet: $OK#9a
< 1> send packet: +
< 86> send packet: $qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+#2e
@saolsen
saolsen / day10.rs
Last active December 11, 2022 18:49
aoc 2022 day10
enum Op {
Noop,
Addx(i32),
}
fn parse<'a>(input: &'a str) -> impl Iterator<Item = Op> + 'a {
input.split("\n").map(|line| {
let mut split = line.split(" ");
let op = split.next().unwrap();
match op {