Skip to content

Instantly share code, notes, and snippets.

View tresf's full-sized avatar

Tres Finocchiaro tresf

View GitHub Profile
@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/ && \
#!/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) {
@tresf
tresf / print.js
Created February 2, 2023 23:38
QZ Tray + ThermalPrinterEncoder (Node.js)
let tpe = require('thermal-printer-encoder');
let ws = require('ws');
let qz = require('qz-tray');
let encoder = new tpe({
language: 'esc-pos'
});
let result = encoder
.initialize()

Batch QZ Tray Session Stealer

Custom session stealer for Windows fast user switching

For a pure PowerShell solution, see here instead: https://gist.github.com/tresf/4e19e15ad38354af6732ee701c990102

Problem

  • QZ Tray is a singleton application, so only one instance can run at a time.
  • Windows fast-user switching feature leaves applications running when a new user signs onto a shared workstation
  • QZ Tray can "steal" the instance, however this is retroactive and places a burden on the user
@tresf
tresf / README.MD
Last active August 18, 2024 17:51
PowerShell QZ Tray Session Stealer (for Windows fast user switching)

PowerShell QZ Tray Session Stealer

Custom session stealer for Windows fast user switching

For a pure Batch solution, see here instead: https://gist.github.com/tresf/ff91bd29f1f6846c13bf6f8bc255ab55

Problem

  • QZ Tray is a singleton application, so only one instance can run at a time.
  • Windows fast-user switching feature leaves applications running when a new user signs onto a shared workstation
  • QZ Tray can "steal" the instance, however this is retroactive and places a burden on the user
@tresf
tresf / active_sessions.ps1
Last active December 14, 2022 17:44
PowerShell: Get active windows login sessions
# Adopted from: https://www.reddit.com/r/PowerShell/comments/306mcn/wtsenumeratesessions/
# Original Author: u/geostude
$_WTSMyStruct_Def = @'
namespace mystruct {
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
public struct WTS_SESSION_INFO {
public Int32 SessionID;
@tresf
tresf / qz-tray-properties.bat
Last active November 16, 2022 17:24
Add entry to properties file
@echo off
NET SESSION >nul 2>&1
if %ERRORLEVEL% EQU 0 (
echo Administrator PRIVILEGES Detected!
) else (
echo NOT AN ADMIN!
pause
exit
)
~LOGO;LOGO-QZ-0;128;256;DOTS
1;1-256
2;1;66;68;70;72;74;82;84;256
3;1;64;67;69;71;83;85;256
4;1;61;63;65;67;84;86;256
5;1;58;60;62;64;86;88;256
6;1;53;55;57;59;61;87;89;256
7;1;51;54;56;58;87;89;91;256
8;1;47;49;51;53;55;89;91;256
9;1;44;46;48;50;52;90;92;256
@tresf
tresf / hello-pdfbox.py
Last active November 19, 2024 19:03
Python PDFBOX Example
# Hello PDFBOX - A suprisingly simple example for calling PDFBOX from Python
#
# Author: Tres Finocchiaro
# License: WTFPL
# STEPS:
# macOS:
# brew install python openjdk@11
# pip3 install jpype1
#