Skip to content

Instantly share code, notes, and snippets.

View cgutwin's full-sized avatar

Chris Gutwin cgutwin

View GitHub Profile
@cgutwin
cgutwin / Scanner.tsx
Created November 30, 2021 20:20
Quagga 2 Implementation in Typescript
import React, { useRef, useState } from "react"
import styled from "styled-components"
import useScanner from "./useScanner"
import type { QuaggaJSResultObject } from "@ericblade/quagga2"
interface ScannerProps extends React.HTMLAttributes<HTMLDivElement> {
active: boolean
onResults: any
}
@cgutwin
cgutwin / nginxDockerBaremetalProxy.md
Last active February 23, 2022 23:05
Setting up nginx baremetal to proxypass to nginx docker services.

f33 server

sudo dnf update

Docker

Install Docker

sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
@cgutwin
cgutwin / QuaggaScanner.jsx
Last active September 17, 2020 06:38
An implementation of the Quagga QR scanner as a React component.
// Copyright (c) 2020 Chris Gutwin. All rights reserved.
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://choosealicense.com/licenses/mit/>.
//
// An implementation of the Quagga 1 QR scanner as a React component.
// Mitigates false positives by quickly taking multiple scans, and using the most detected of n = 40 scans.
// This isn't really needed anymore from my limited testing, Quagga 2 (@ericblade/quagga2) seems to have fewer false positives.
// Feel free to abstract away the non-React functions. They clutter up the component and make it feel non-component like.
import Quagga from 'quagga'
import React, { useEffect, useState } from 'react'
@cgutwin
cgutwin / httpRequestLoggerMiddleware.js
Created July 2, 2019 22:02
An Express middleware function to log incoming HTTP requests, with basic formatting of objects.
/*
* Will accept an object, and add a carriage return to the end of each entry
* to format for console readability.
* */
const formatObject = (obj) => {
let formattedObject = ``
/*
Some items might come in empty (such as params, query, body), so if it's
empty, just skip over it.
@cgutwin
cgutwin / AccountEncryption.js
Last active May 24, 2024 06:07
Two-way encryption for user data (in this case, an account password) utilizing three different values for the encryption key, with NodeJS.
/*
* Encryption for the added user accounts and passwords
*
* Reference:
* https://stackoverflow.com/a/5093422
* */
require('dotenv').config()
const CRYPTO = require('crypto')
const Encryption = require('./Encryption')