Skip to content

Instantly share code, notes, and snippets.

View faceslog's full-sized avatar
:dependabot:
Hello

faces faceslog

:dependabot:
Hello
View GitHub Profile
@faceslog
faceslog / README.md
Last active July 29, 2023 20:49
Extract and assemble frames from a video using opencv used to create Stable Diffusion Video

Extract the frames

Create a virtual env

python -m venv myenv
# To activate the environment on Windows:
./myenv/Scripts/Activate.ps1
# To activate the environment on Linux:
source myenv/bin/activate
@faceslog
faceslog / EventHandler.h
Last active January 2, 2023 21:24
DummyEventHandlerCpp
#pragma once
#include <string>
#include <unordered_map>
#include <functional>
// Define a type for the event handler function
using EventHandlerFunc = std::function<void(void)>;
class EventHandler
@faceslog
faceslog / httplogger.js
Last active November 28, 2022 20:25
Nodejs Middleware to Log HTTP API-Requests when working with an API without any doc :kappa:
const http = require("http");
const server = http.createServer((request, response) => {
const requestStart = Date.now();
let errorMessage = null;
let body = [];
request.on("data", chunk => {
body.push(chunk);
});
@faceslog
faceslog / ufw-cf.sh
Last active January 2, 2023 19:33
Whitelist cloudflare IPs in UFW from (https://github.com/drvy/ufw-cloudflare)
#!/bin/sh
cfufw_deleted=0
cfufw_created=0
cfufw_ignored=0
cfufw_nonew=0
cfufw_purge=0
cfufw_showhelp=0
cf_ufw_add () {
@faceslog
faceslog / README.md
Last active November 28, 2022 09:24
Use discord webhook to monitor ssh login

Post a webhook embed when someone is connecting via ssh to your server

To install

wget https://gist.githubusercontent.com/faceslog/e45fcaf85932f619fdaa8ae54b25cf38/raw/c4f3959bb7d1f30e49ef7b746c1f74bd07a97943/install.sh

chmod +x install.sh

bash install.sh [WEBHOOK URL]

@faceslog
faceslog / Welford.hpp
Created August 7, 2022 19:00
Welford's online algorithm (C++) often useful to be able to compute the variance in a single pass
#pragma once
#include <cmath>
// Welford's online algorithm:
// https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#On-line_algorithm
// It is often useful to be able to compute the variance in a single pass
/**
* EXAMPLE: