Skip to content

Instantly share code, notes, and snippets.

View tresf's full-sized avatar

Tres Finocchiaro tresf

View GitHub Profile
// From https://github.com/WebBluetoothCG/demos/blob/gh-pages/bluetooth-printer/index.html
var SERVICE = '000018f0-0000-1000-8000-00805f9b34fb';
var WRITE = '00002af1-0000-1000-8000-00805f9b34fb';
var DATA = ''
+ '\x1B' + '\x61' + '\x31' // center align
+ '\x1D' + '\x21' + '\x11' + 'Hello\nBluetooth!\n\n' // double font size
+ '\x1D' + '\x21' + '\x00' + '... from your friends\nat https://qz.io' // normal font size
+ '\n\n\n\n\n\n\n'; // feed paper
@tresf
tresf / LMMS No Admin.md
Last active April 16, 2024 01:00
Install LMMS without Admin

Install LMMS without Admin

  1. Download 7zip portable, extract to the Desktop

  2. Download LMMS

  3. Open a command prompt, paste in the following:

    %USERPROFILE%\Desktop\7-ZipPortable\App\7-Zip\7z.exe x %USERPROFILE%\Downloads\lmms-1.2.0-rc6-win64.exe -x!$PLUGINSDIR -o%USERPROFILE%\Desktop\LMMS
  4. Should output this:

@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 / scale-zpl.js
Last active March 5, 2024 14:37
(Experimental) Scales a Raw ZPL file from 203 DPI (dots per inch) to 300 DPI
/*
* author: Tres Finocchiaro
* date: 2015-05-22
* license: Public Domain; Use as you wish.
* source: http://qz.io
*/
/*
* Scales text from a raw ZPL label from 203 DPI to 300 DPI
*/
@tresf
tresf / ScaleFactor.java
Last active February 22, 2024 16:04
Scale Factor Test
import com.sun.jna.platform.win32.GDI32;
import com.sun.jna.platform.win32.WinDef;
import java.awt.*;
public class Main {
public static void main(String[] args) {
float toolkit = 0;
@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 / Default.aspx
Last active November 23, 2023 07:02
C# PageMethods Signing
<script type="text/javascript" src="js/qz-tray.js"></script>
<script>
qz.security.setSignatureAlgorithm("SHA512"); // Use "SHA1" for QZ Tray 2.0 and older
qz.security.setSignaturePromise(function (toSign) {
return function (resolve, reject) {
PageMethods.SignMessage(toSign, resolve, reject);
};
});
@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; \
@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 / golang_qz_tray.go
Last active September 27, 2023 06:50
Golang QZ Tray
package main
import (
"log"
"time"
"io/ioutil"
"crypto/rsa"
"encoding/pem"
"crypto/x509"
"crypto/sha1"