Skip to content

Instantly share code, notes, and snippets.

View jmpinit's full-sized avatar

Owen Trueblood jmpinit

View GitHub Profile
@jmpinit
jmpinit / filter-gh-articles.js
Last active May 20, 2023 16:01
A Greasemonkey/Tampermonkey/Violentmonkey user script to automatically remove articles of specific types from the GitHub feed. Also registers disinterest for each of them so they may show up less often.
// ==UserScript==
// @name Remove published releases from GitHub feed
// @namespace Violentmonkey Scripts
// @match https://github.com/
// @grant none
// @version 1.0
// @author Owen Trueblood
// @description Remove published releases from GitHub feed
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
@jmpinit
jmpinit / receive_cam.py
Created May 2, 2023 19:30
Very simple low latency camera streaming in Python with OpenCV and ZeroMQ.
import sys
import cv2
import zmq
import base64
import numpy as np
context = zmq.Context()
footage_socket = context.socket(zmq.SUB)
footage_socket.connect('tcp://localhost:5555')
@jmpinit
jmpinit / flip-point-over-line.js
Created April 21, 2023 15:50
Flip a 3D point over a line defined by two 3D points
export function flipPointOverLine(linePoint1, linePoint2, point) {
// Calculate the vector that represents the line direction
const lineVector = vec3.create();
vec3.subtract(lineVector, linePoint2, linePoint1);
vec3.normalize(lineVector, lineVector);
// Calculate the projection of the point onto the line
// relative to the start of the line
const pointToLinePoint1 = vec3.subtract(vec3.create(), point, linePoint1);
const dotProduct = vec3.dot(pointToLinePoint1, lineVector);
@jmpinit
jmpinit / print_stack_usage.c
Created February 16, 2023 15:51
Print the stack usage of the current Zephyr thread.
void print_thread_stack_usage() {
struct k_thread* thread = k_current_get();
size_t stack_space;
k_thread_stack_space_get(thread, &stack_space);
printk("Thread has %u bytes of stack space left.\n", stack_space);
}
@jmpinit
jmpinit / .gitignore
Last active January 25, 2023 01:09
Example of using Python to do board layout in KiCad.
# Reports
*.rpt
# CPL data generated from PCB
*.pos
# KiCad backup
*.bak
*.bck
*.kicad_pcb-bak
@jmpinit
jmpinit / Code.gs
Created December 1, 2022 17:38
App Script to add an "Events" label to GMail messages sent from Google Calendar.
function threadHasLabel(thread, labelName) {
var existingLabels = thread.getLabels();
for (var i = 0; i < existingLabels.length; i++) {
if (existingLabels[i].getName() === labelName) {
return true;
}
}
return false;
SUBSYSTEM=="tty", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="fd92", SYMLINK+="ttyAxiDraw", RUN+="/bin/sh -c 'socat -s /dev/ttyS0,raw,echo=0,ignoreeof,iexten=0,b115200 /dev/ttyAxiDraw,raw,echo=0,ignoreeof,iexten=0,b115200'"
function fooBar() {
console.log('hello world!');
}
@jmpinit
jmpinit / axidraw.js
Created November 21, 2022 11:44
Controlling an AxiDraw in real-time from P5.js
let reader;
let writer;
let connected = false;
let wasConnected = false;
let drawing = false;
const encoder = new TextEncoder();
const decoder = new TextDecoder();
let lastX = 0;
@jmpinit
jmpinit / Podfile
Created October 26, 2021 16:26
Fix Xcode 12.5 React Native build
# https://github.com/facebook/react-native/issues/28405#issuecomment-827421253
post_install do |installer|
## Fix for XCode 12.5 beta
find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
"RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
end