Skip to content

Instantly share code, notes, and snippets.

View benjamind's full-sized avatar

Ben Delarre benjamind

View GitHub Profile
@benjamind
benjamind / Networking Fix.md
Last active June 9, 2022 16:47
GlobalProtect WSL 2 Networking fix

Add the following as a scheduled task:

$wslInterface = (Get-NetAdapter | Where-Object Name -like "*(WSL)*" | Where-Object Status -like "Up" | Get-NetIPAddress -AddressFamily IPv4)
$wslIP = (wsl hostname -I)
$wslIF = $wslInterface.InterfaceIndex
Invoke-Expression "route add $wslIP mask 255.255.255.255 $wslIP metric 256 if $wslIF"

Triggered on Log Microsoft-Windows-NetworkProfile/Operational Source NetworkProfile EventID 10000 with administrator privileges.

@benjamind
benjamind / global.d.ts
Created July 19, 2019 22:38
Typings for semantic-dom-diff and test-helpers from openwc project
declare namespace Chai {
interface Assertion {
dom: Assertion;
shadowDom: Assertion;
lightDom: Assertion;
}
}
declare module '@open-wc/semantic-dom-diff' {
/**
Debug: 17 3 options.c:96 add_default_dirs(): bindir=/builds/6694ddf5/0/idf/openocd-esp32/openocd-esp32/bin
Debug: 18 3 options.c:97 add_default_dirs(): pkgdatadir=/builds/6694ddf5/0/idf/openocd-esp32/openocd-esp32/share/openocd
Debug: 19 3 options.c:98 add_default_dirs(): run_prefix=D:/Tools/openocd-esp32/bin
Debug: 20 3 configuration.c:42 add_script_search_dir(): adding C:\msys32\home\ben/.openocd
Debug: 21 3 configuration.c:42 add_script_search_dir(): adding C:\Users\ben\AppData\Roaming/OpenOCD
Debug: 22 3 configuration.c:42 add_script_search_dir(): adding D:/Tools/openocd-esp32/bin/builds/6694ddf5/0/idf/openocd-esp32/openocd-esp32/share/openocd/site
Debug: 23 3 configuration.c:42 add_script_search_dir(): adding D:/Tools/openocd-esp32/bin/builds/6694ddf5/0/idf/openocd-esp32/openocd-esp32/share/openocd/scripts
Debug: 24 4 configuration.c:82 find_file(): found share/openocd/scripts/interface/ftdi/tumpa.cfg
Debug: 25 5 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_interface ftdi
Debu
@benjamind
benjamind / flashinglog.txt
Created October 22, 2017 02:21
ESP32 JTag Flashing failure
Debug: 17 3 options.c:96 add_default_dirs(): bindir=/builds/6694ddf5/0/idf/openocd-esp32/openocd-esp32/bin
Debug: 18 3 options.c:97 add_default_dirs(): pkgdatadir=/builds/6694ddf5/0/idf/openocd-esp32/openocd-esp32/share/openocd
Debug: 19 3 options.c:98 add_default_dirs(): run_prefix=D:/Tools/openocd-esp32/bin
Debug: 20 3 configuration.c:42 add_script_search_dir(): adding C:\msys32\home\ben/.openocd
Debug: 21 3 configuration.c:42 add_script_search_dir(): adding C:\Users\ben\AppData\Roaming/OpenOCD
Debug: 22 3 configuration.c:42 add_script_search_dir(): adding D:/Tools/openocd-esp32/bin/builds/6694ddf5/0/idf/openocd-esp32/openocd-esp32/share/openocd/site
Debug: 23 4 configuration.c:42 add_script_search_dir(): adding D:/Tools/openocd-esp32/bin/builds/6694ddf5/0/idf/openocd-esp32/openocd-esp32/share/openocd/scripts
Debug: 24 4 configuration.c:82 find_file(): found share/openocd/scripts/interface/ftdi/tumpa.cfg
Debug: 25 5 command.c:143 script_debug(): command - ocd_command ocd_command type ocd_interface ftdi
Debu
Loaded https://mongoose-os.com/downloads/api.json
[Sep 10 19:39:06.139] I0910 19:39:06.139165 11880 mgrpc.go:208] Connecting to COM6 over tSerial
[Sep 10 19:39:06.139] I0910 19:39:06.139165 11880 reconnect_wrapper.go:79] Next attempt: 2017-09-10 19:39:06.1391654 -0700 PDT, Now: 2017-09-10 19:39:06.1391654 -0700 PDT, Diff: 0
[Sep 10 19:39:06.139] I0910 19:39:06.139165 11880 mgrpc.go:272] Started recv loop, codec: [reconnectWrapperCodec to COM6; connecting...]
[Sep 10 19:39:06.139] I0910 19:39:06.139165 11880 mgrpc.go:274] recv ...
[Sep 10 19:39:06.139] I0910 19:39:06.139165 11880 reconnect_wrapper.go:87] [reconnectWrapperCodec to COM6; connecting...] connecting
[Sep 10 19:39:06.139] I0910 19:39:06.139165 11880 serial.go:63] Opening COM6...
[Sep 10 19:39:06.158] I0910 19:39:06.158183 11880 serial.go:73] COM6 opened: &{0x136e6070 856 {0 0} {0 0} 0x136e22a0 0x136e22c0}, err: <nil>
[Sep 10 19:39:06.159] I0910 19:39:06.158183 11880 reconnect_wrapper.go:98] [reconnectWrapperCodec to COM6; connected]
@benjamind
benjamind / gist:e62f5177a975086051b19f35475e8713
Created January 8, 2017 21:10
FastLED power management per controller pseudocode
// this is all pseudocode and will probably not compile but it should give you an idea
// init...
// create your controllers
CLEDController controllerA = FastLED.addLEDs(LED_TYPE, DATA_PIN, COLOR_ORDER(ledsA, 0, NUM_LEDS_A);
CLEDController controllerB = FastLED.addLEDs(LED_TYPE, DATA_PIN, COLOR_ORDER(ledsB, 0, NUM_LEDS_B);
// loop....
// calculate power per controller
uint8_t scaleA = calculate_max_brightness_for_power_mW(controllerA.leds(), controllerA.size(), targetBrightness, MAX_POWER_MW_A);
// include the neo pixel library
#include <Adafruit_NeoPixel.h>
// how many leds in our string?
static const int NUM_LEDS = 5;
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream
@benjamind
benjamind / led-sender.js
Last active July 30, 2016 19:14
Sending LED data over Serial with NodeJS
var serialport = require("serialport"),
SerialPort = serialport.SerialPort;
// first list the serial ports available so we can figure out which is the arduino
serialport.list(function (err, ports) {
var port = null;
ports.forEach(function(p) {
// this should work on windows and maybe osx
if (p.manufacturer.indexOf('Arduino')!==-1) {
port = p.comName;
@benjamind
benjamind / gist:6199599
Created August 10, 2013 08:31
More LED testing...
// include the neo pixel library
#include <Adafruit_NeoPixel.h>
// how many leds in our string?
static const int NUM_LEDS =21*6;
static const int TOTAL_BYTES = NUM_LEDS*3;
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
@benjamind
benjamind / gist:6199413
Created August 10, 2013 07:02
Neo pixel led test
// include the neo pixel library
#include <Adafruit_NeoPixel.h>
// how many leds in our string?
static const int NUM_LEDS = 6;
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream