Skip to content

Instantly share code, notes, and snippets.

View tresf's full-sized avatar

Tres Finocchiaro tresf

View GitHub Profile
@tresf
tresf / DarwinHidApiLibrary.java
Last active June 6, 2024 18:52
Thread safe wrapping of hid4java calls
package org.hid4java.jna;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.WString;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
# Downloads an executable from the provided URL for use in a build system
# and optionally prepends it to the PATH
#
# Assumes:
# - CMAKE_CURRENT_BINARY_DIR/[${_name}]
# - CPACK_CURRENT_BINARY_DIR/[${_name}]
# - Fallback to $ENV{TMPDIR}/[RANDOM]/[${_name}]
# - For verbose, set COMMAND_ECHO to STDOUT in calling script
#
macro(download_binary RESULT_VARIABLE _url _name _prepend_to_path)
@tresf
tresf / wrongbrew.sh
Last active May 25, 2024 07:45
Homebrew, but for the wrong architecture
#!/usr/bin/env bash
#
# Install wrong architecture packages on macOS
# - Can only install one package at a time, unless using "brew bundle"
# - Uses `brew deps --tree` to loop over dependencies
# - For speed, tries to NOT upgrade a package automatically
# - To upgrade a package, use wrongbrew.sh uninstall <packagename> && wrongbrew.sh install <packagename>
# - Based on the example from @maxirmx https://stackoverflow.com/a/70822921/3196753
# Halt on first error
@tresf
tresf / LMMS aarch64.md
Last active May 21, 2024 04:43
Cross-compile LMMS for ARM64

Description

This tutorial was written for Ubuntu 20.04 and is based off of lmms/wiki/Compiling. It adapt well to other Ubuntu verisons or Linux distros, but the package names and sources.list entries will change.

Warning

Warning, this configuration uses ARM64 "port" versions of Ubuntu libraries which cause havoc on apt and the dependency chain. Don't do this on your main machine, or even one you slighlty care about.

Configure modern cmake

@tresf
tresf / unofficial-qz-7zip-installer.bat
Last active April 4, 2024 16:15
Unofficial QZ Tray + 7zip Installer
@ECHO OFF
SET INSTALLER=qz-tray-2.2.3-x86_64.exe
SET TEMPQZ=%USERPROFILE%\tempqz
SET SEVENZIP=%PROGRAMFILES%\7-Zip\7z.exe
REM Preflight: Check for admin
NET SESSION >nul 2>&1
IF %ERRORLEVEL% EQU 0 (
REM Admin confirmed
) ELSE (
@tresf
tresf / ntk.md
Last active December 26, 2023 21:18
LMMS + Zyn + Non Toolkit

How to build NTK:

(adapted from Albrecht Schlosser)

  1. Install dependencies:
    sudo apt-get install \
       fontconfig \
       libxft-dev \
       libcairo2-dev \

libjpeg-dev \

@tresf
tresf / temurin_21_qemu_riscv.log
Created November 3, 2023 19:34
Temurin 21 RISC-V QEmu
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0xffffffff9053df5e, pid=3312, tid=3313
#
# JRE version: (21.0.1+12) (build )
# Java VM: OpenJDK 64-Bit Server VM (21.0.1-beta+12-ea, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)
# Problematic frame:
# j java.lang.System.registerNatives()V+0 java.base
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
@tresf
tresf / qemu_macos.md
Last active November 4, 2023 15:02
QEmu with Java MacOS Apple Silicon M1/M2/M3
wget https://download2.gluonhq.com/openjfx/19/openjfx-19_monocle-linux-x64_bin-sdk.zip -O \
out/javafx-linux-x86_64-19_monocle.zip && unzip out/javafx-linux-x86_64-19_monocle.zip && \
cp -R javafx-sdk-19 lib/javafx-linux-x86_64-19_monocle && mv javafx-sdk-19 out/javafx-linux-x86_64-19_monocle
pushd ~/Applications/qemu/debian-riscv64/ &amp;&amp; \
#!/bin/bash
keywords=('developer-low' 'door-open' 'fuser-over-temp' 'fuser-under-temp' 'input-tray-missing' 'interlock-open' 'interpreter-resource-unavailable' 'marker-supply-empty' 'marker-supply-low' 'marker-waste-almost-full' 'marker-waste-full' 'media-empty' 'media-jam' 'media-low' 'media-needed' 'moving-to-paused' 'opc-life-over' 'opc-near-eol' 'output-area-almost-full' 'output-area-full' 'output-tray-missing' 'paused' 'shutdown' 'spool-area-full' 'stopped-partly' 'stopping' 'timed-out' 'toner-empty' 'toner-low')
echo "INFO: This is an informational message, I guess?" >&2
for i in {1..290}
do
echo "STATE: ${keywords[$i % 29]}" >&2
sleep .1
done
@tresf
tresf / sign-message.deno.js
Created March 23, 2023 14:46
Signing using Deno + QZ Tray
/**
* Author: A. Tres Finocchiaro
* License: Public Domain
*/
import "https://raw.githubusercontent.com/qzind/tray/v2.2.2/js/qz-tray.js";
import { encode, decode } from "https://deno.land/std/encoding/base64.ts";
// Load certificate
qz.security.setCertificatePromise(function(resolve, reject) {