Skip to content

Instantly share code, notes, and snippets.

@cowboy
cowboy / route-search.sh
Last active August 16, 2024 11:30
Elite: Dangerous, Trade Dangerous wrapper script
#!/usr/bin/env bash
userprofile_dir=$(wslpath "$(wslvar USERPROFILE)")
journal_dir="$userprofile_dir/Saved Games/Frontier Developments/Elite Dangerous"
status_file="$journal_dir/Status.json"
journal_credits=$(cat "$status_file" | jq -r .Balance)
[[ "$journal_credits" == null ]] && journal_credits=999999999
# journal_system_id=$(cat "$status_file" | jq -r .Destination.System)
# journal_system_name=$(curl -s https://spansh.co.uk/api/system/$journal_system_id | jq -r .record.name)
@cowboy
cowboy / jrs-syncatron.c
Last active February 3, 2024 17:42
JRS syncatron
// To give your project a unique name, this code must be
// placed into a .c file (its own tab). It can not be in
// a .cpp file or your main sketch (the .ino file).
#include "usb_names.h"
// Edit these lines to create your own name. The length must
// match the number of characters in your custom name.
#define MIDI_NAME {'S','y','n','c','a','t','r','o','n'}
@cowboy
cowboy / name_of_script.cmd
Last active July 3, 2024 09:37
bash script in a Windows cmd file, so you can double-click and run right from Explorer
:<<"::CMDLITERAL"
@echo off
FOR /F "tokens=* USEBACKQ" %%F IN (`wsl wslpath '%~f0'`) DO (
SET script_path=%%F
)
bash -c "'%script_path%'"
exit /b
::CMDLITERAL
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
@cowboy
cowboy / usb-din-midi-device.c
Last active December 11, 2023 08:44
USB MIDI device -> filter -> DIN MIDI out - for Teensy LC
// To give your project a unique name, this code must be
// placed into a .c file (its own tab). It can not be in
// a .cpp file or your main sketch (the .ino file).
#include "usb_names.h"
// Edit these lines to create your own name. The length must
// match the number of characters in your custom name.
#define MIDI_NAME {'R','e','n','a','m','e',' ','M','e',' ','D','u','d','e'}
@cowboy
cowboy / cowboy-launchkey-mini-mk3-supercharger.c
Last active July 27, 2023 04:37
Launchkey Mini MK3 Supercharger (USB MIDI) - for Teensy 4.1
// To give your project a unique name, this code must be
// placed into a .c file (its own tab). It can not be in
// a .cpp file or your main sketch (the .ino file).
#include "usb_names.h"
// Edit these lines to create your own name. The length must
// match the number of characters in your custom name.
#define MIDI_NAME {'C','B',' ','S','u','p','e','r',' ','L','a','u','n','c','h','k','e','y'}
@cowboy
cowboy / teensy-41-usbmidi-issue
Created August 23, 2022 04:36
Teensy 4.1 USB MIDI issue: note on/off messages get dropped when enough keys are pressed/released simultaneously (MIDI controller connected to USB host port, PC running MIDI OX connected to micro USB port)
// Settings:
// Tools > Board = "Teensy 4.1"
// Tools > USB Type to "MIDI"
#include <USBHost_t36.h> // access to USB MIDI devices (plugged into 2nd USB port)
// Create the ports for USB devices plugged into Teensy's 2nd USB port (via hubs)
USBHost myusb;
USBHub hub1(myusb);
MIDIDevice midiDevice(myusb);
@cowboy
cowboy / cowboy-midi-sustain-filter.c
Last active December 22, 2023 21:51
USB MIDI "proxy" that converts Note On + Sustain + Note Off => Note On + "Sustained" Note Off for devices that don't handle Sustain (CC 64) well
// To give your project a unique name, this code must be
// placed into a .c file (its own tab). It can not be in
// a .cpp file or your main sketch (the .ino file).
#include "usb_names.h"
// Edit these lines to create your own name. The length must
// match the number of characters in your custom name.
#define MIDI_NAME {'C', 'o', 'w', 'b', 'o', 'y', ' ', 'F', 'i', 'l', 't', 'e', 'r'}
@cowboy
cowboy / cowboy.scad
Last active June 21, 2022 02:14
OpenSCAD utility modules
// ===============================================================
// Misc utilities for OpenSCAD
// 2022 "Cowboy" Ben Alman
//
// https://gist.github.com/cowboy/0a536021bcf1d07b2a59e808dcddd278
// ===============================================================
// Epsilon value for merging solids
eps=0.001;
// ===============================================================
// MIDI to 24 PPQN Clock + Run (USB MIDI) - Teensy LC Firmware
// "Cowboy" Ben Alman, 2022
// https://gist.github.com/cowboy/1af3a69d4b6cae6a099fcf76431bda02
// ===============================================================
int PPQN = 24;
int RUN_PIN = 26;
int RUN_LED_PIN = 20;
@cowboy
cowboy / run-in-console.js
Last active September 8, 2023 09:45
Amits Launch Pad Pro Light Show Editor - Unofficial Launchpad Mini Mk3 support
// Run this in the console at https://midi.amitszone.com/LPP_LIGHTSHOW_BUILDER/
// to get it to work with the Launchpad Mini Mk3. It may work with other new
// Launchpads, I'm not sure (If it does, comment below, thanks!)
(() => {
// Create mapping of Launchpad Pro -> Mini Mk3 notes
// (This is only the mapping for the 8x8 grid area)
const noteMap = {}
for (let i = 1; i <= 8; i++) {
for (let j = 1; j <= 8; j++) {