Skip to content

Instantly share code, notes, and snippets.

@johnholbrook
johnholbrook / iq_fcc.py
Created May 26, 2023 18:27
Field-Centric control code for a VEX IQ X-Drive robot
# ------------------------------------------
#
# Project: VEX IQ Field-Centric Holonomic Drive
# Author: John Holbrook
# Created: May 2023
# Description: Drive code for a VEX IQ X-drive robot with field-centric drive
# (i.e., pushing the stick up makes the robot drive in a constant
# direction regardless of heading).
#
# ------------------------------------------
@johnholbrook
johnholbrook / tm.ahk
Last active January 4, 2021 01:40
AutoHotkey script for automating various aspects of VEX Tournament Manager
; ----------------------------------------------------------------------------------------------------------------------
; File .........: tm.ahk
; Description ..: AutoHotkey script for automating various aspects of VEX Tournament Manager
; Authors ......: John Holbrook (johnholbrook.us) and Philip Taylor (philipt.net)
; Changelog ....: 31 Dec. 2020 - Initial release
; ..............: 03 Jan. 2021 - Scaled all window coordinate clicks by screen DPI (function correct_for_dpi)
; NOTES ........: 1 - Due to unknown incompatabilities in the ExtListView library, this script must be run
; ..............: under a 32-bit version on AutoHotkey.
; ..............: 2 - Some parts of this script can be a little janky if you have multiple displays and they're not all
; ..............: at the same UI scaling level. In that case, make sure the TM window is on your primary display,
@johnholbrook
johnholbrook / ExtListView.ahk
Created December 31, 2020 14:49
Modified & Extended version of ExtListView AutoHotkey library
; ----------------------------------------------------------------------------------------------------------------------
; Name ............: ExtListView library
; Description .....: Collection of functions dealing with the ListViews of external processes.
; AHK Version .....: AHK_L 1.1.13.01 x32/64 ANSI/Unicode
; Original Author .: Cyruz - http://ciroprincipe.info
; Modified By .....: Philip Taylor & John Holbrook
; License .........: WTFPL - http://www.wtfpl.net/txt/copying/
; Changelog .......: May 18, 2013 - v0.1 - First revision.
; .................: Jun. 28, 2013 - v0.2 - Added resizable buffer option.
; .................: Feb. 04, 2014 - v0.3 - Unicode and x64 compatibility.
@johnholbrook
johnholbrook / livestream_alert.sh
Last active October 5, 2020 13:26
Alert when livestream appears to go down
youtube-dl -o /dev/null $1 | python ytdl-filter.py
afplay alarm.mp3
say "stream appears to have ended"
@johnholbrook
johnholbrook / ldcad_wine.md
Last active April 17, 2023 21:13
Running LDCad for VEX IQ on macOS via Wine

Running LDCad for VEX IQ on macOS via Wine

This guide reviews steps for running LDCad for VEX IQ on macOS using Wine. It assumes some basic familiarity with navigating directories using the terminal (with basic commands such as cd and ls), but should otherwise be pretty easy to follow.

Wine is described as follows:

Wine (originally an acronym for "Wine Is Not an Emulator") is a compatibility layer capable of running Windows applications on several POSIX-compliant operating systems, such as Linux, macOS, & BSD. Instead of simulating internal Windows logic like a virtual machine or emulator, Wine translates Windows API calls into POSIX calls on-the-fly, eliminating the performance and memory penalties of other methods and allowing you to cleanly integrate Windows applications into your desktop.

Wine could also be used to run LDCad on Linux; however, an official Linux build of LDCad is available so this isn't necessary.

@johnholbrook
johnholbrook / stl_to_ldraw.py
Created May 12, 2020 04:07
Python script to convert a plaintext STL (read from stdin) to LDraw part format (printed to stdout)
# read from stdin
import sys
lines = sys.stdin.readlines()
# extract the points from the STL
points = []
for line in lines:
split = line.split()
if split[0] == "vertex":
(p1, p2, p3) = (float(split[1]), float(split[2]), float(split[3]))
#returns true if strings a and b contain the same letter count
# (i.e., a can be rearranged to form b)
def compare(a,b):
return sorted([i for i in a]) == sorted([i for i in b])
def main():
contents = []
# open the file and separate into lines
with open("enable1.txt", "r") as f:
contents = f.readlines()
for i in {1..30}
do
echo "Loop $i"
youtube-dl -a list.txt
done
@johnholbrook
johnholbrook / view_post_source.js
Last active June 26, 2019 19:03
Tampermonkey script to add 'view post source' button to Discourse forum posts
// ==UserScript==
// @name Discourse View Post Source
// @namespace jholbrook
// @author John Holbrook
// @version 0.1
// @description Adds a 'view post source' button to posts on Discourse forums
// @website https://gist.github.com/dhmmjoph/77edfd56cd54e65acbd4877e3154458a
//Change these or add aditional sites here:
// @match https://www.vexforum.com/t/*
<?php
echo "Hello World!";
function make_packet($data)
{
$bytes = str_split($data, 2);
$buffer = "\x55\xff\x00";
$sum = 0;
foreach ($bytes as $byte) {
$byte = hexdec($byte);
$sum += $byte;