Skip to content

Instantly share code, notes, and snippets.

@lynaghk
lynaghk / jlcpcb_xls2csv.py
Created February 6, 2021 07:37
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/
#!/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 September 24, 2019 18:43
streaming realsense depth map video over network
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 September 4, 2019 06:11
Reinforcement learning sketch
(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 January 24, 2023 22:37
# A big and slow sketch useful for perf testing.
# A big and slow sketch useful for perf testing.
A
A1 -> A2
A2 -> A3
A3 -> A4
A1
A2
A3
A4
@lynaghk
lynaghk / sketch systems grammar.md
Last active March 20, 2022 20:11
Sketch.systems grammar

Sketch.systems uses the wonderful Instaparse Clojure(Script) library to parse statechart specifications. Unfortunately, the current grammar is quite memory intensive and on larger specs suffers from multi-second garbage collection pauses.

Suggestions welcome!

@lynaghk
lynaghk / 1-readme.md
Created November 25, 2018 00:31
shipping puzzle in minizinc

First pass at shipping puzzle in MiniZinc. See https://kevinlynagh.com/notes/shipping-puzzle/

Runs in 2.5 seconds on my 2013 macbook air. Anything more than 7 routes takes more than a few minutes (and I stopped waiting).

I tried to improve perf by breaking symmetry in the rows of routes by ordering the routes according to the first leg. (i.e., the first non-zero value in a row of routes should be less than the first non-zero value of the next row of routes) But I couldn't figure out how to do that neatly.

1 LOS_ANGELES CHARLOTTE F
2 CHARLOTTE NEW_YORK W
3 NEW_YORK JACKSONVILLE F
4 JACKSONVILLE SAN_JOSE R
5 SAN_JOSE DETROIT T
6 DETROIT SEATTLE R
7 SEATTLE AUSTIN T
8 AUSTIN COLUMBUS W
9 COLUMBUS PHILADELPHIA T
10 PHILADELPHIA PHOENIX T
@lynaghk
lynaghk / gist:f6a25748ca748ddb122146eb7e2e3a3c
Created September 25, 2018 16:53
Sketch systems grammar EBNF
<statechart> = (state / <whitespace> / <comments>)+
state = comments? state-name <whitespace>? <newline> block?
transition = comments? event-name <whitespace>? <'->'> <whitespace>? state-name <newline>
<block> = indent (state / transition / <whitespace> / <comments>)+ dedent
comments = comment (<newline> comment)* <newline>
<comment> = <'#'> #".*"
@lynaghk
lynaghk / jug.als
Last active August 25, 2018 11:25
Another Alloy jug puzzle
open util/ordering[State]
sig Jug {
max: Int
}
abstract sig Op {}
sig Pour extends Op {
@lynaghk
lynaghk / SketchSystems.spec
Last active August 7, 2018 17:28
# Test parallel spec.
# Test parallel spec.
Search Inactive
touch search bar -> Search Active
Search Active&
touch cancel -> Search Inactive
touch result -> View Result
text input -> Loading