Skip to content

Instantly share code, notes, and snippets.

let print_row row =
Array.map print_char row |> ignore;
print_newline ()
let rule n = function
| ('_', '_', '_') -> if n land 0b00000001 = 0 then '_' else '*'
| ('_', '_', '*') -> if n land 0b00000010 = 0 then '_' else '*'
| ('_', '*', '_') -> if n land 0b00000100 = 0 then '_' else '*'
| ('_', '*', '*') -> if n land 0b00001000 = 0 then '_' else '*'
@joncfoo
joncfoo / main.go
Last active August 29, 2024 15:10
Peer Credentials from Unix Domain Socket
// Unix Domain Socket Peer Credentials
//
// This program demonstrates setting up a HTTP server over a Unix Domain Socket
// and subsequently obtaining connecting clients credentials. The credentials
// contain the User ID, Group ID, and Process ID of the incoming connection (as
// connections are made by some local system user as opposed to a network
// connection).
//
// This has interesting use cases around local process security. For example,
// a server listening on a Unix Domain Socket can choose to allow or reject
@joncfoo
joncfoo / day01-1.awk
Last active December 22, 2022 23:06
advent of code 2022
#!/usr/bin/env awk -f
BEGIN { RS = ""; FS = "\n"; }
{
for (i=1; i<=NF; i++) {
sum += $i
}
if (sum > max) {
max = sum