Skip to content

Instantly share code, notes, and snippets.

View signalwerk's full-sized avatar
💫
on the r͢oad

Stefan Huber signalwerk

💫
on the r͢oad
View GitHub Profile
#!/bin/bash
# Replace these with your Pushover credentials
APP_TOKEN="your_app_token"
USER_KEY="your_user_key"
# Expected IP addresses
EXPECTED_IP_A="your_expected_ipv64_address"
EXPECTED_IP_AAAA="your_expected_ipv6_address"
@signalwerk
signalwerk / index.mjs
Last active October 18, 2024 06:46
CLI screenshot helper
#!/usr/bin/env node
import puppeteer from "puppeteer";
import { URL } from "url";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import fs from "fs";
import path from "path";
const INDENT = " ";
@signalwerk
signalwerk / grid.scss
Last active June 3, 2024 15:46
Draw the columns of a grid in the background
.container-grid {
--columns: 6;
--gap: 1.5rem;
position: relative;
overflow: hidden;
display: grid;
grid-template-columns: repeat(var(--columns), 1fr);
grid-column-gap: var(--gap);
@signalwerk
signalwerk / convert.sh
Last active April 24, 2024 22:29
Convert a video to HLS format with multiple resolutions
#!/usr/bin/env bash
# Convert a video to HLS format with multiple resolutions
# Usage: ./convert.sh input.mp4
# current version:
# https://gist.github.com/signalwerk/5eaddbd2825501e4ea61784efbf84a31
# for more complex converting see also
# https://gist.github.com/mrbar42/ae111731906f958b396f30906004b3fa
@signalwerk
signalwerk / useFetch.js
Created January 10, 2024 22:59
Fetch a JSON and have the option to chancel the request
import { useState, useEffect } from "react";
const useFetch = (url, options) => {
const [response, setResponse] = useState(null);
const [error, setError] = useState(null);
const [loading, setLoading] = useState(false);
const abortController = new AbortController(); // Move abortController outside useEffect
useEffect(() => {
const signal = abortController.signal;
@signalwerk
signalwerk / count.sh
Last active August 8, 2023 15:53
Count code lines in git repo
#!/bin/bash
# run
# bash <(curl https://gist.githubusercontent.com/signalwerk/7b4411c13073da371b5d3d5d4d73cc9b/raw/count.sh)
# Define the output CSV file
output_csv="code_lines.csv"
# Header for the CSV file
echo "Commit,Year,Month,Date,Total Lines,Largest File" > "$output_csv"
@signalwerk
signalwerk / index.html
Last active June 2, 2023 11:58
Slideshow for Marc Rudin
<!DOCTYPE html>
<html>
<head>
<title>Marc Rudin</title>
<style>
body,
html {
margin: 0;
padding: 0;
height: 100%;
@signalwerk
signalwerk / form.js
Last active May 21, 2023 22:47
Conditional form handling based on JSON-Definiton
// Latest Vesrsion
// curl https://gist.githubusercontent.com/signalwerk/9802b92b6606d4ec2aca58d8f0def4be/raw/form.js > form.js
//
// Example:
//
// document.addEventListener("DOMContentLoaded", (event) => {
// const formCondition = document.querySelector("input[id$=condition]");
// if (formCondition) {
// form(JSON.parse(formCondition.value));
// }
@signalwerk
signalwerk / html-yaml-cli.js
Last active July 12, 2024 14:52
A tool to extract content from HTML, convert it to YAML, and update HTML content from YAML files.
// HTML to YAML Extractor and Updater
/**
* A tool to extract content from HTML, convert it to YAML, and update HTML content from YAML files.
*/
import cheerio from "cheerio";
import { promises as fs } from "fs";
import path from "path";
import yaml from "js-yaml";
@signalwerk
signalwerk / ChatGPT.mjs
Created April 29, 2023 18:24
Minimal ChatGPT request to the OpenAI-API
// This code sends a prompt to the OpenAI API and then outputs the response
// to the terminal and to a file.
// Setup:
// npm init -y && npm i dotenv node-fetch
// echo "OPENAI_API_KEY=sk-XXX" > .env
import fs from "fs";
import fetch from "node-fetch";
import * as dotenv from "dotenv";