Skip to content

Instantly share code, notes, and snippets.

@andrewb435
andrewb435 / MT6835Programmer.ino
Created June 20, 2024 22:31
MT6835 Magnetic Encoder Programmer Sketch for Arduino
/*
Depends on 'Simple FOC' and 'SimpleFOCDrivers' from Arduino Library Manager
Uses default hardware SPI pins for whatever board you run it on
Should be pretty cross-compatible.
Commands are outlined in cliGetCommandParse and cliSetCommandParse, and
are preceeded by a 'g' or 's' to get or set <setting> and then configuration
is ended with a 's save' to save to onboard registers
e.g.
@RoganDawes
RoganDawes / TeensyMonitor.ino
Last active October 23, 2020 13:56
Some Quick and Dirty python code for reading from two serial ports at once. Also, a Teensy sketch for doing the same using actual simultaneous UARTs.
#include <elapsedMillis.h>
#define PIN_D2 2
#define MAX_BUFFER 16
uint8_t buffer1[MAX_BUFFER], buffer1pos = 0, buffer3[MAX_BUFFER], buffer3pos = 0;
char buffer1prefix[] = "E> ", buffer3prefix[] = "A> ";
elapsedMillis TimeSinceRead;
@andrecalvo
andrecalvo / useDataApi.boilerplate.test.jsx
Last active March 11, 2022 12:22
React hook to call an API using fetch with test examples
import React from "react";
import { useDataApi } from "path/to/hoo/useDataApi.jsx";
import "whatwg-fetch";
import { renderHook } from "@testing-library/react-hooks";
import fetchMock from "fetch-mock";
import { act } from "react-test-renderer";
describe("useDataApi", () => {
beforeAll(() => {
global.fetch = fetch;
@cdleon
cdleon / macbook-pro-2011-defective-gpu-fix.md
Last active July 22, 2025 01:39
Macbook Pro 2011 GPU Defect fix macOS Sierra and High Sierra
@rlueder
rlueder / rename.js
Last active May 17, 2024 01:56 — forked from microbial/rename.js
lodash helpers - rename (renames object keys)
/*
* var person = { firstName: 'bill', lastName: 'johnson' }
*
* person = _.rename(person, 'firstName', 'first')
* person = _.rename(person, 'lastName', 'last')
*
* console.log(person) // { first: 'bill', last: 'johnson' }
*/
_.rename = (obj, key, newKey) => {
@RoganDawes
RoganDawes / read_serial.py
Created March 3, 2016 15:50
Simple python script to read two serial ports at the same time. Good for snooping on bidirectional comms!
#!/usr/bin/python3
import serial, time, sys, threading
from colorama import Fore, Style, init as colorama_init
colorama_init()
# lock to serialize console output
lock = threading.Lock()
@esromneb
esromneb / debounce.py
Created November 12, 2015 01:57
This is a proper debounce function, the way a electrical engineer would think about it.
import time
""" This is a proper debounce function, the way a electrical engineer would think about it.
This wrapper never calls sleep. It has two counters: one for successful calls, and one for rejected calls.
If the wrapped function throws an exception, the counters and debounce timer are still correct """
class Debounce(object):
def __init__(self, period):