Skip to content

Instantly share code, notes, and snippets.

View robert-kratz's full-sized avatar
😷

Robert J. Kratz robert-kratz

😷
View GitHub Profile
@robert-kratz
robert-kratz / nginx-start-docker
Created May 18, 2024 14:17
This script will build a docker file for a webserver, then it will secure it via ssl and deploy the webserver.
#!/bin/bash
# Check if the correct number of arguments is provided
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <domain> <port> <dockerfile_dir> <email>"
exit 1
fi
DOMAIN=$1
PORT=$2
@robert-kratz
robert-kratz / JPGtojpgConvertion.js
Created December 24, 2023 00:29
This script converts all images ending on .JPG to lowercase .jpg
const fs = require("fs");
const path = require("path");
const directoryPath = "./input"; // Replace with your directory path
fs.readdir(directoryPath, (err, files) => {
if (err) {
console.error("Error reading the directory", err);
return;
}
@robert-kratz
robert-kratz / Reponse.js
Created November 27, 2022 12:22
NodeJS Express response formatter
module.exports = class Response {
constructor(response) {
this.code = response.statusCode;
this.date = new Date();
this.error = [];
this.data = {};
return this;
@robert-kratz
robert-kratz / BackToTopButton.js
Created October 14, 2022 18:16
A back to top button for react/nextjs
import { Fragment, useEffect, useState } from "react"
export default function BackToTopButton() {
const [show, setShow] = useState(false);
useEffect(() => {
window.addEventListener('scroll', () => {
if (window.scrollY > 200) {
setShow(true);
@robert-kratz
robert-kratz / Crypto.js
Created January 18, 2022 19:41
NodeJS Bycript hashing methods
const bcrypt = require('bcrypt');
module.exports = {
/**
* Use this to hash a password
* @param {String} input
* @returns Promise<String>
*/
encript: (input) => {
return new Promise((resolve, rejects) => {
@robert-kratz
robert-kratz / googleauth.js
Last active December 6, 2021 11:57
NodeJS Google Authenticator Module using Axios
const axios = require('axios').default;
const secret = 'SECRET';
const appname = 'Your-App';
/**
* Google Authenticator API: https://authenticatorapi.com/
*
* App Store: https://apps.apple.com/de/app/google-authenticator/id388497605
* Play Store: https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=de&gl=US