Skip to content

Instantly share code, notes, and snippets.


Jaremy Creechley elcritch

View GitHub Profile
elcritch / settings_nvs_esp32.nim
Created Jun 15, 2022
Example NVS Setting Object (ESP-IDF)
View settings_nvs_esp32.nim
## 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 / pararulesStaticEx.nim
Created May 16, 2022
pararules static example
View pararulesStaticEx.nim
import pararules
import std/[times, monotimes, os, strformat, strutils, sequtils, sugar]
Id = enum
Global, Player, Derived
Attr = enum
elcritch /
Created Mar 8, 2022
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 / kalman_simple.nim
Last active Feb 26, 2022
Example Nim port of a Kalman filter
View kalman_simple.nim
## * A simple kalman filter example by Adrian Boeing
## original at:
## 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
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 \
# Useful helpers for manjaro
sh -c "$(curl -fsSL"
elcritch / dts_example.nim
Created Oct 5, 2021
Example of DTS tree encoded into a pure Nim Macro
View dts_example.nim
&mikrobus_i2c {
status = "okay",
spi-max-frequency = `<100000>`,
status: "okay"
click_spi2: spi-device@1 {
View linux-keybindings.json
// Place your key bindings in this file to override the defaults
{ "key": "meta+f", "command": "actions.find",
"when": "editorFocus || editorIsOpen" },
{ "key": "meta+s", "command": "" },
{ "key": "meta+g", "command": "editor.action.nextMatchFindAction",
"when": "editorFocus" },
{ "key": "meta+a", "command": "editor.action.selectAll" },
{ "key": "meta+c", "command": "editor.action.clipboardCopyAction" },
{ "key": "meta+x", "command": "editor.action.clipboardCutAction" },
elcritch /
Created May 19, 2021
Manjaro dev tools setup because I always forget
sudo pacman -Syu base-devel --needed
elcritch / usbreset.nim
Created Mar 12, 2021
usbreset.nim -- Nim version of USB port reset on Linux
View usbreset.nim
## usbreset -- linux program reset a usb port using /dev/ttyUSB<n> file paths
# usage: usbreset /dev/ttyUSB0
# Install:
# nim c usbreset.nim
# sudo cp usbreset /usr/local/bin
# Setuid to not need sudo (at your own peril):
# sudo chmod 4555 /usr/local/bin/usbreset
import os, system, osproc, posix, strutils, re, strformat