Skip to content

Instantly share code, notes, and snippets.

Tres Finocchiaro tresf

Block or report user

Report or block tresf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tresf
tresf / WebViewResize.java
Created Jan 18, 2020
Trying to fix race conditions in WebView
View WebViewResize.java
import com.sun.javafx.tk.TKPulseListener;
import com.sun.javafx.tk.Toolkit;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.Scene;
import javafx.scene.SnapshotParameters;
View WebViewResize.java
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.Scene;
import javafx.scene.SnapshotParameters;
import javafx.scene.image.WritableImage;
import javafx.scene.web.WebView;
View WebApp.java
package qz.printer.action;
import javafx.animation.PauseTransition;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.ActionEvent;
View PrintHTMLStub.java
package qz.printer.action;
import com.github.zafarkhaja.semver.Version;
import qz.common.Constants;
import qz.deploy.DeployUtilities;
import qz.utils.SystemUtilities;
import java.awt.image.BufferedImage;
import java.awt.print.Printable;
import java.io.File;
import java.util.Date;
View qz-node.js
var qz = require("qz-tray"); // 2.1.0-2 or higher to fix #543
// Use default Proimse provided by Node.js
qz.api.setPromiseType(function promise(resolver) { return new Promise(resolver); });
// Simulate the browser's version of the websocket
qz.api.setWebSocketType(require('websocket').w3cwebsocket);
// Node 4.5 doesn't come with crypto, use sha.js instead
var createHash = require('sha.js');
View network_compat.diff
diff --git a/js/qz-tray.js b/js/qz-tray.js
index 8455a7f..7e1e0ea 100644
--- a/js/qz-tray.js
+++ b/js/qz-tray.js
@@ -528,8 +528,7 @@ var qz = (function() {
isAlgorithmCompatible: function() {
//if not connected yet we will assume compatibility exists for the time being
if (_qz.websocket.connection) {
- var semver = _qz.websocket.connection.version.split(/[.-]/g);
- if (semver[0] === "2" && semver[1] === "0") {
View sign-message-sha256.js
// API
setSignaturePromise: function(promiseGen, alg) {
_qz.security.signaturePromise = promiseGen;
// TODO: Detect QZ version, warn
_qz.security.signatureAlg = alg;
}
// Implementation
View gist:a3b2c0c82f25afa24b43fbbc020f2065
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@tresf
tresf / make-service.bat
Last active Nov 18, 2019
QZ Tray Service
View make-service.bat
REM ###### 1. Run the site to be using QZ Tray and click "Remember this decision"
REM ###### 2. Create a batch file that launches QZ Tray
echo java -Xms512M -jar "%~dp0\qz-tray.jar" %* > "%PROGRAMFILES%\QZ Tray\qz-tray.bat"
REM ###### 3. Make a location for SYSTEM certificate white-list
mkdir "%WINDIR%\System32\config\systemprofile\AppData\Roaming\qz"
REM ###### 4. Copy the "allowed.dat" to the SYSTEM
copy /Y "%APPDATA%\qz\allowed.dat" "%WINDIR%\System32\config\systemprofile\AppData\Roaming\qz\allowed.dat"
View fix_blank_pages.java
String[] methods = { "impl_updatePeer", "doUpdatePeer" };
for(String method : methods) {
for(Method m : webView.getClass().getDeclaredMethods()) {
if(m.getName().equals(method)) {
if(!m.isAccessible()) {
m.setAccessible(true);
}
try {
m.invoke(webView);
You can’t perform that action at this time.