Skip to content

Instantly share code, notes, and snippets.

@lynaghk
lynaghk / taxes.smt2
Created Aug 1, 2022
S-Corp tax optimization with the Z3 Theorem Prover
View taxes.smt2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Solo freelancer's S-Corp tax optimization
;;
;; Assumes an unmarried single-shareholder and tons of other stuff.
;; I'm not a tax professional, no guarantees here, probably typos, etc. Come on!
;; Run with https://github.com/Z3Prover/z3
;;
;; See also my notes at https://kevinlynagh.com/financial-plan/
@lynaghk
lynaghk / 0_readme.md
Last active Jul 22, 2022
earthly vs toast
View 0_readme.md

Comparing Earthly and Toast for isolated / repeatable development.

Calculate a performance floor by running a fast command, echo, in the context of a large container (the emscripten SDK takes up about 1 GB).

After the initial build and caching, Toast takes 800ms and Earthly about 7 seconds on my 2020 M1 Macbook Air.

  • MacOS 12.5
  • Docker Desktop 4.10.1
  • Toast 0.45.5
  • Earthly v0.6.20 ad869c06c884b10f88948b5852ab22b4d7262e20
@lynaghk
lynaghk / user.clj
Created Mar 18, 2022
Rel and Datascript comparison
View user.clj
;; A comparison of Rel: https://docs.relational.ai/rel/primer/aggregations_groupby_joins
;; with datascript: https://github.com/tonsky/datascript/
;; Unless otherwise indicated, all datascript outputs match the ones shown in the Rel Primer.
(ns user
(:require [datascript.core :as d]
clojure.string))
(def csv
"Messi,70,32,BFC,Argentina
@lynaghk
lynaghk / 0_WebRTC_serverless_demo.md
Last active Jul 15, 2022
"Serverless" WebRTC demo.
View 0_WebRTC_serverless_demo.md

"Serverless" WebRTC demo

Start a server on localhost and open index.html (the host) and index.html#client (the client) in two different browser windows. They'll do their lil' p2p connection discovery dance via the wonderful public service that is https://patchbay.pub/ and, once established, a video-only camera feed from the client will display on the host.

View resistors.csv
id val
C4410 1000
C17985 750
C17887 300
C17900 100000
C17901 100
C17902 10000
C17903 10
C17924 180
C17928 1
@lynaghk
lynaghk / jlcpcb_xls2csv.py
Created Feb 6, 2021
Download JLCPCB part library as a spreadsheet (https://jlcpcb.com/parts) then turn it into a sqlite database so you can search/view/sort parts using https://sqlitebrowser.org/
View jlcpcb_xls2csv.py
#!/usr/bin/env python
import xlrd
import os
import sys
import csv
import re
re_px = re.compile(":([0-9.]+)")
@lynaghk
lynaghk / lib.rs
Created Sep 24, 2019
streaming realsense depth map video over network
View lib.rs
pub mod network;
pub mod realsense_bindings;
pub type CameraTimestamp = u64;
pub const WIDTH: usize = 640;
pub const HEIGHT: usize = 480;
pub const FPS: usize = 30;
pub const FRAME_SIZE: usize = WIDTH * HEIGHT * 2; //16 bit depth info
pub const RECIEVER_ADDR: &'static str = "192.168.1.2:9898";
@lynaghk
lynaghk / reinforcement_learning.clj
Created Sep 4, 2019
Reinforcement learning sketch
View reinforcement_learning.clj
(ns reinforcement-learning
(:require [clojure.set :refer [difference union]]
[clojure.string :as str]
[lonocloud.synthread :as ->]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Tic Tac Toe bits
;; based on https://github.com/paraseba/tictactoe/blob/master/src/tictactoe/core.clj
@lynaghk
lynaghk / SketchSystems.spec
Last active Jan 24, 2023
# A big and slow sketch useful for perf testing.
View SketchSystems.spec
# A big and slow sketch useful for perf testing.
A
A1 -> A2
A2 -> A3
A3 -> A4
A1
A2
A3
A4