Skip to content

Instantly share code, notes, and snippets.

Avatar

Jaremy Creechley elcritch

View GitHub Profile
@elcritch
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
elcritch / pararulesStaticEx.nim
Created May 16, 2022
pararules static example
View pararulesStaticEx.nim
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 Mar 8, 2022
Handy IoT IPv6 Commands
View commands-ipv6.sh
## 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 Feb 26, 2022
Example Nim port of a Kalman filter
View kalman_simple.nim
## * 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
View 00-setup-zephyr-opensuse.sh
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
View 00-setup-linux.sh
# Useful helpers for manjaro
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
@elcritch
elcritch / dts_example.nim
Created Oct 5, 2021
Example of DTS tree encoded into a pure Nim Macro
View dts_example.nim
deviceTree:
&mikrobus_i2c {
status = "okay",
spi-max-frequency = `<100000>`,
}
&mikrobus_spi:
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": "workbench.action.files.save" },
{ "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
elcritch / setup.sh
Created May 19, 2021
Manjaro dev tools setup because I always forget
View setup.sh
sudo pacman -Syu base-devel --needed
@elcritch
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