Skip to content

Instantly share code, notes, and snippets.

@qnxdev
qnxdev / setImageToLocalstorage.js
Last active September 29, 2024 15:43
Storing image in localStorage in React
import { useEffect } from "react";
export default function SetImage() {
const saveImage = (e) => {
const file = e.target.files[0];
const reader = new FileReader();
reader.onloadend = () => {
// convert file to base64 String
const base64String = reader.result
.replace("data:", "")
@akbertram
akbertram / README.md
Last active February 22, 2024 10:39
Fingerprint Scanning with WebUSB

These are notes regarding an experimental attempt to operate a SecuGen HU20 fingerprint scanner with WebUSB. I wanted to learn a bit about the WebUSB protocol and to assess how feasible such a project would be.

The ideal is that our web application would be able to interact directly with the Fingerprint Scanner on a Windows, Mac or Android Tablet or phone without having to muck around with drivers or other installed software.

Problems

There are unfortunately two principle problems that undermine this ideal.

The first and most significant from my point of view is that interacting with the Fingerprint Scanner requires significant mucking about on Windows

Line Properties broker1 Values (mosquitto.br_conf) broker0 Values (mosquitto.conf) Description
210 port 1884 1883 Port to use for the default listener
310 tls_version tlsv1.2 tlsv1.2 the version of the TLS protocol to use for this listener
374 listener - 8883 listener port-number [ip address/host name]
450 cafile - C:\...\mosquitto\certs\ca.crt defines the path to a file containing the CA certificates
454 certfile - C:\...\mosquitto\certs\server.crt Path to the PEM encoded server certificate
457 keyfile - C:\...\mosquitto\certs\server.key Path to the PEM encoded keyfile
651 allow_anonymous false false If `password_file` or `psk_file` is set
669 password_file C:\...\mosquitto\passwordfile.pwd C:\...\mosquitto\passwordfile.pwd If password_file is set the auth_plugin check will be made first
728 acl_file C:\...\mosquitto\acl.acl C:\...\mosquitto\acl.acl If acl_file is set the auth_plugin check will be made first
@kjanshair
kjanshair / docker-compose-traefik.yml
Last active December 19, 2023 00:22
docker-compose Traefik
version: "3.3"
services:
traefik:
image: traefik:latest
container_name: traefik
environment:
# COMMON
- TRAEFIK_API_INSECURE=true # Enable Traefik dashboard
- TRAEFIK_PROVIDERS_DOCKER=true # Enable Docker provider
@aspose-com-gists
aspose-com-gists / convert-cf2-to-bmp.cs
Last active November 1, 2025 19:35
Convert CAD DXG DXF DWFX to Raster Images C#
// load CF2 in an instance of Image via its Load method
using (var image = Image.Load("template.cf2"))
{
// create an instance of CadRasterizationOptions and set page height & width
var rasterizationOptions = new ImageOptions.CadRasterizationOptions()
{
PageWidth = 1600,
PageHeight = 1600
};
@natcl
natcl / docker-compose.yaml
Last active May 21, 2024 04:37
traefik: node-red + mosquitto using letsencrypt
version: "3.3"
services:
traefik:
image: "traefik:v2.2"
container_name: "traefik"
command:
- "--api=true"
- "--api.dashboard=true"
@RobinCPC
RobinCPC / wine_setup.md
Last active July 31, 2025 14:13
Wine Setup

Install Wine with Mono & Gecko in Ubuntu 20.04

Warning: Do not try those command in your main PC, I test in a virtual Machine

Note: Most of commands are from the Dockerfile in Reference section. If you want to test wine, just run their docker container

1. Setup PPA

sudo dpkg --add-architecture i386
wget -qO - https://dl.winehq.org/wine-builds/winehq.key | sudo tee /etc/apt/trusted.gpg.d/winehq.asc
@kostja-me
kostja-me / settings.py
Last active November 9, 2023 03:40
Nginx Cache Setup for Django Site. Uses Django Dummy Cache Backend by default to set required Cache-Control Headers for downstream Nginx Cache
REDIS_URL = os.getenv('REDIS_URL', 'redis://localhost:6379')
CACHES = {
"redis": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": REDIS_URL,
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
},
"default": {
@phnahes
phnahes / bcd.bat
Created April 17, 2020 21:45
Clone HDD to SSD and using SSD for Boot and System (UEFI)
# Boot a LiveCD linux and install clonezilla
apt update && apt install clonezilla -y
# Using Gparted, clone partitions in the same type, size and flags from source disk (sda) on target target(sdb)
# After, using clonezilla, clone part_to_part
# sda1 to sdb1
# sda2 to sdb2
# sda3 to sdb3
#
@gimiki
gimiki / traefik_tcp_mqtt_mosquitto_docker_compose.md
Last active September 2, 2025 18:47
Traefik Reverse Proxy - Mosquitto MQTT Broker - Docker Container

This gist is to configure a Mosquitto MQTT Broker behind a Traefik reverse-proxy, both in a docker container. Mosquitto will be configuread as a TCP Service.

This is a simple configuration used on the same single server. Probably to be adapted for other cases. Having mosquitto behind a reverse proxy enables you to configure TLS on Traefik (likely you already do that for other applications as well) and to load balance different MQTT instances, but that goes beyond this gist.

As noted in Traefik docs, in the router you must use the rule HostSNI(`*`) when using non-TLS routers like in this example. Ref. https://docs.traefik.io/routing/routers/#rule_1

docker-compose.yml