Skip to content

Instantly share code, notes, and snippets.

@Slyke
Slyke / install_ssh_keys.sh
Last active September 12, 2022 09:12
Automatic Install SSH Keys
#!/bin/bash
# Created by: Slyke
# Email: [email protected]
# Version: 3
# Date: 2022-09-10
# This script allows you to automatically install SSH keys from your github account, and optionally disable password authentication for sshd.
# Best to clone this script to your own github gist and curl it from there, instead of using mine.
# It is also better to dump this to a file locally and run it from there if placed in a cronjob.
# License: MIT
@Slyke
Slyke / organiseGoPro.js
Last active August 16, 2021 06:51
GoPro - Organise and merge video files
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process')
const baseDir = './';
const videoFileTypes = ['mp4', 'mov', 'avi', 'wmv', 'mkv', 'flv', 'mpg', 'mpeg', '3gp', '3g2'];
const allFiles = fs.readdirSync(baseDir);
const videoFiles = [];
@Slyke
Slyke / gist:d0b84367fbfb59aa7fb9095458c567b6
Last active April 27, 2023 23:23
Database of devices
{
devices: {
bedroomLight: {
type: "switch"
},
denLight: {
type: "dimmable"
},
livingroomLight: {
type: "dimmable"
@Slyke
Slyke / _
Last active November 1, 2023 10:12
DHCP alerts (NodeRed/sh)
Instructions:
1. Install 'arp_monitor.sh' file on DHCP server and setup cronjob.
2. Copy the flow from flow.json and import into Nodered.
The '.function-node' Javascript files are provided for ease of reading. The code within these files is already in the flow.
Take note of the ARP debouncing. You may want to adjust the timings if you are getting false online/offline alerts, or it isn't quick enough for you.
Variabes are:
@Slyke
Slyke / gist:bcd4cdf09a683772ca99ce87571d1b63
Created August 9, 2023 22:02
Encrypt and decrypt text
async function deriveKey(plaintextKey) {
const baseKey = await window.crypto.subtle.importKey("raw", new TextEncoder().encode(plaintextKey), "PBKDF2", false, ["deriveKey"]);
return window.crypto.subtle.deriveKey(
{
name: "PBKDF2",
salt: new TextEncoder().encode("some-salt"),
iterations: 10000,
hash: "SHA-256"
},
baseKey,
@Slyke
Slyke / interpolate.js
Created October 17, 2023 09:52
Javascript/NodeJS String Interpolation
/**
* Interpolates a string template with values from an object or array.
*
* @param {string} template - The string containing placeholders to be interpolated.
* @param {Object|Array} values - An object or array containing values to replace the placeholders.
* @param {string|boolean} [fallback=""] - Value to use when a placeholder's corresponding key is not found.
* If set to `true`, the placeholder itself is used as the fallback.
*
* @returns {string} - The interpolated string.
*
@Slyke
Slyke / docker-compose.yml
Last active March 4, 2024 09:02
Docker-Compose: ZeroTier Controller, WUI, Router
version: '3.8'
services:
postgres:
image: postgres:15.5-alpine
container_name: postgres-zt
volumes:
- ./volumes/postgres:/var/lib/postgresql/data
environment:
POSTGRES_DB: ztnet