Skip to content

Instantly share code, notes, and snippets.

View netskink's full-sized avatar

John F. Davis netskink

View GitHub Profile
@netskink
netskink / fileio.swift
Last active February 24, 2023 16:19
try catch in swift and variable visibility
func mySimpleFileRead(path: String) throws -> UnitsData {
let fileName = (path as NSString).expandingTildeInPath
let url = URL(fileURLWithPath: fileName)
let data = try Data(contentsOf: url)
return try JSONDecoder().decode(UnitsData.self, from: data)
}
@netskink
netskink / mkrnb1500.ino
Created September 7, 2021 16:52
mkrnb1500.ino get serial buffer to empty?
/*
This code clears the u-blox on a MKR NB 1500 of all certificates.
*/
// baud rate used for both Serial ports
unsigned long baud = 115200;
// Must be large enough to capture all
@netskink
netskink / up_mon0.sh
Last active July 25, 2021 03:28
script for wireshark setup
# have the channels to be the same.
DEFAULT_CHANNEL=11
echo "Setting up wifi monitor interface on" $WIPHY
#ORIG sudo iw phy $WIPHY interface add mon0 type monitor flags none control otherbss
sudo iw $WIPHY interface add mon0 type monitor flags none control otherbss
echo "Bringing up $MONIF"
#ORIG sudo ifconfig mon0 up promisc
# I did this by accident. In case it mattered. I already had the network in use so no telling.
@netskink
netskink / afilename
Last active July 23, 2021 20:37
Trying to debug why I can not get the arduino connected to Google Cloud Platform IoT Core via MQTT
# Background
So, filed an issue with the arduino gcp library I am using. Its (here)[https://github.com/GoogleCloudPlatform/google-cloud-iot-arduino/issues/230]
# Pivot
I was looking through code and getting lost, so I thought it might be helpful to see what happens in wireshark.
I figure I don't know SSL/TLS so at least just running a tool might enlighten me about the subject as well as perhaps
see where the failure occurs. For instance in GCP I dont see any errors in logs, so I am very concerned that it might be
failing after getting time sync from ntp server prior to first reporting of telemetry via mqtt. (From my limited time with
the code tracing it fails on the first read with a read failure error).
@netskink
netskink / gist:f54cc0767e788058385ea3f3b7ba0c77
Created July 23, 2021 15:00
wifi101 ip and mac address dump
void setupWifi() {
Serial.println("Starting wifi");
WiFi.begin(ssid, password);
Serial.println("Connecting to WiFi");
while (WiFi.status() != WL_CONNECTED) {
delay(100);
}
Serial.println("Waiting on time sync...");
sobel_vertical = nd.array((
(1,0,-1),
(2,0,-2),
(1,0,-1)
))
print("\nSobel vertical transform Gx", end='')
print(sobel_vertical)
rotation_90_x = nd.array((
( 1, 0, 0),
@netskink
netskink / testy.py
Last active June 5, 2020 03:00
switch implemented with a dictionary
def one():
return "this is function one"
def two():
return "this is function two"
def three():
return "this is function three"
@netskink
netskink / ns_Heap.py
Created May 2, 2020 00:19
binary heap class
a min heap implementation for use with micropython
class ns_Heap(object):
""""
Attributes:
heap: List representation of a min heap
@netskink
netskink / diagram.md
Last active May 7, 2020 00:08
state machine demo

alt text

@netskink
netskink / ns_MouseAction.py
Last active April 29, 2020 19:53
a state machine
# Example usage of state machine class
#
#
#
class ns_MouseAction:
def __init__(self, action):
self.action = action
def __str__(self):