Skip to content

Instantly share code, notes, and snippets.

View elcritch's full-sized avatar

Jaremy Creechley elcritch

View GitHub Profile
@elcritch
elcritch / NocdeA.md
Created November 2, 2023 00:38
codex-two-client-test

metric: connmanager.nim(221) muxCleanup count: 1 avg execTime: 25us542ns total: 25us542ns avg wallTime: 49us625ns total: 49us625ns avg runTime: 49us584ns total: 49us584ns

metric: asyncsync.nim(367) popFirst count: 47690 avg execTime: 1us385ns total: 66ms56us535ns avg wallTime: 129ms128us33ns total: 1h42m38s115ms901us655ns

@elcritch
elcritch / case_types.nim
Created June 12, 2023 23:09
Experiment with Nim Pattern Matching Syntax
import macros
type
EitherKind {.pure.} = enum
Some, None
Either[T] = object
case kind: EitherKind
of Some:
@elcritch
elcritch / rfc idea.md
Last active June 9, 2023 22:17
Omnimvore Error Handling

RFC Draft: Omnimvore Error Handling

This RFC presents an attempt to unify parts of the syntatical styles between exceptions vs results based error handling techniques. The two styles can be implemented in a somewhat similar fashion under the covers, but do offer quite different ergonomics. In an ideal world we can take the best from both styles as fits a given situation.

The core idea of this RFC is to present a gradual typing like system for enhancing error typing. This provides attempts to provide a best of all worlds and let folks decide how strictly they want to track their error types in a given set of code.

Another idea is to provide a seamless integration from full exceptions to enum based error codes. While it provides nice ergonomics, this may not be desirable at an implementation level though.

Syntax Proposal and Compiler Checks

@elcritch
elcritch / devcontainer.json
Created May 16, 2023 19:38
vscode devcontainer for esp-idf and nesper
{
"name": "esp-idf",
"image": "ghcr.io/embeddednim/esp-idf:4.4-2023-02-12",
"remoteUser": "root",
"postCreateCommand": "git config --global --add safe.directory '*' && sh -c \"$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) --skip-chsh\" ",
// "postStartCommand": "",
"customizations": {
"vscode": {
"extensions": [
"nimsaem.nimvscode",
@elcritch
elcritch / settings_nvs_esp32.nim
Created June 15, 2022 07:21
Example NVS Setting Object (ESP-IDF)
## Example usage of NVS
## license: Apache-2.0
import macros, strutils, md5, options
import json
import nesper
import nesper/net_utils
import nesper/consts, nesper/general
import nesper/nvs_utils
@elcritch
elcritch / pararulesStaticEx.nim
Created May 16, 2022 02:35
pararules static example
import pararules
import std/[times, monotimes, os, strformat, strutils, sequtils, sugar]
type
Id = enum
Global, Player, Derived
Attr = enum
DeltaTime,
TotalTime,
X,
@elcritch
elcritch / commands-ipv6.sh
Created March 8, 2022 03:01
Handy IoT IPv6 Commands
## Find all link-local devices on an interface
## - helpful for fiding all devices on a given switch
ping6 -I eth0 ff02::1
## use link-local ipv6 addresses to keep
## a constant device ip even when it's connected
## on different networks
ping -6 fe80::9090:a32:63b1:ee75%eth0
@elcritch
elcritch / kalman_simple.nim
Last active February 26, 2022 09:38
Example Nim port of a Kalman filter
## * A simple kalman filter example by Adrian Boeing
## www.adrianboeing.com
## original at: https://gist.github.com/jannson/9951716
## Note: I imported this to Nim, but haven't run or tested it.
import std/random, std/strformat, std/math
proc runKalman*() =
## initial values for the kalman filter
@elcritch
elcritch / 00-setup-zephyr-opensuse.sh
Created December 7, 2021 01:43
Setup Zephyr Linux
sudo zypper in libusb-compat-devel
sudo zypper in mbedtls-devel libmbedtls13
sudo zypper in usbsdmux-udev udev-browse udev-extra-rules
sudo zypper install git cmake ninja-build gperf ccache dfu-util dtc wget \
python3-pip python3-tkinter xz file glibc-devel libstdc++-devel python38 \
SDL2-devel