Skip to content

Instantly share code, notes, and snippets.

View tresf's full-sized avatar

Tres Finocchiaro tresf

View GitHub Profile
@tresf
tresf / CFG.html
Last active September 29, 2026 01:22
FGL Printing Examples
<F3>
<RC10,10>Serial Number = <VA1>
<RC60,10>Firmware = <VA7>
<RC110,10>Special Head = <VA18>
<RC160,10>Font File = <VA2>
<RC210,10>Printer Type = <VA11>
<RC260,10>DPI = <VA17>
<RC310,10>Expansion Mem = <VA50>
<RC360,10>Path Type = <VA19>
<RC410,10>Ticket Type = <VA13>
// 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 / zpl.js
Last active March 31, 2026 20:06
ZPL Label Sample
/*
* The re-use of the ZPL syntax and US Shipping Label
* - Provided as education example
* - Re-released by open source community under fair use
* - Fair use per US Copyright Act of 1976, 17 U.S.C. § 107
* The ZPL Printer Language
* - Copyright © 2014 ZIH Corp (zebra.com)
* The JavaScript syntax (minus ZPL markdown)
* Copyright © 2015 QZ Industries, LLC (qz.io)
* Licence: LGPL 2.1
// TODO: This successfully replaces the icon but the EXE won't run afterwards
package com.company;
import com.kichik.pecoff4j.PE;
import com.kichik.pecoff4j.ResourceDirectory;
import com.kichik.pecoff4j.ResourceDirectoryTable;
import com.kichik.pecoff4j.ResourceEntry;
import com.kichik.pecoff4j.constant.ResourceType;
import com.kichik.pecoff4j.io.DataReader;
@tresf
tresf / connectAndPrint.js
Last active October 17, 2025 01:58
Connect and print
function connectAndPrint() {
// our promise chain
connect().then(function() {
return print();
}).then(function() {
success(); // exceptions get thrown all the way up the stack
}).catch(fail); // so one catch is often enough for all promises
// NOTE: If a function returns a promise, you don't need to wrap it in a fuction call.
// The following is perfectly valid:
@tresf
tresf / HomeController.cs
Last active June 30, 2025 18:21
C# MVC Signing
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Web.Mvc;
private static X509KeyStorageFlags STORAGE_FLAGS = X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable;
public ActionResult SignMessage()
{
#!/bin/bash
set -e
versions=(
"2.10.1-alpha1"
"2.10.0"
"2.9.6"
"2.9.5"
"2.9.4"
"2.9.3"
@tresf
tresf / legacy_cpp_include.diff
Created April 28, 2025 18:59
MacOSX10.9.sdk: Find c++ standard headers in legacy location
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c7ab0cb..6114abf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,19 @@ if(APPLE)
find_path(IOKit_INCLUDE_DIR NAMES IOKitLib.h HINTS ${IOKit_INC_SEARCH_PATH} ${IOKit_PKGC_INCLUDE_DIRS} PATH_SUFFIXES IOKit)
list(APPEND JSSC_ADDITIONAL_INCLUDES ${IOKit_INCLUDE_DIR})
endif()
+ # Handle edge-case with legacy versioned SDK headers (e.g. usr/include/c++/4.2.1)
+ if(CMAKE_OSX_SYSROOT)
@tresf
tresf / scale-zpl.js
Last active February 6, 2025 16:09
(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
*/
This file has been truncated, but you can view the full file.
AppHack @1.1 aqua/AppHack
AppKiDo @0.988 aqua/AppKiDo
AquaLess @1.6 aqua/AquaLess
ArpSpyX @1.1 aqua/ArpSpyX
AssignmentTrackerX @2.0beta3.1 aqua/AssignmentTrackerX
BGHUDAppKit @0.7 aqua/BGHUDAppKit
BigSQL @1.0 aqua/BigSQL
BiggerSQL @1.3.9 aqua/BiggerSQL
Books @3.2.5c aqua/Books
BwanaDik @3.3 aqua/BwanaDik