Skip to content

Instantly share code, notes, and snippets.

View manix84's full-sized avatar
🧸
Being a parent

Rob Taylor manix84

🧸
Being a parent
View GitHub Profile
@manix84
manix84 / useConsoleOpen.ts
Last active July 2, 2025 11:27
Detect if the user has opened the browser console.
/**
This code is licensed under the terms of the MIT license
*/
import { useEffect, useRef, useState } from 'react';
type UseConsoleOpenOptions = {
onOpen?: () => void;
pollInterval?: number;
};
@manix84
manix84 / config.jsonc
Last active May 15, 2025 12:59
FastFetch Minecraft (redstone) logo
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"modules": [
"title",
"separator",
"os",
"host",
"kernel",
"uptime",
"packages",
@manix84
manix84 / config.jsonc
Last active May 15, 2025 12:25
FastFetch Minecraft logo
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"modules": [
"title",
"separator",
"os",
"host",
"kernel",
"uptime",
"packages",
file_downloader() {
local url="" output=""
local downloader=""
# Parse arguments
while [[ "$#" -gt 0 ]]; do
case "$1" in
--output=*)
output="${1#--output=}"
;;
package_installer() {
local package_manager=""
if command -v apt >/dev/null 2>&1; then
package_manager="apt"
elif command -v yum >/dev/null 2>&1; then
package_manager="yum"
elif command -v dnf >/dev/null 2>&1; then
package_manager="dnf"
elif command -v zypper >/dev/null 2>&1; then
@manix84
manix84 / request.ts
Last active February 8, 2025 18:10
A backend request object, that allows you to abstract away the generic request logic around the specific calls.
/**
This code is licensed under the terms of the MIT license
*/
export class ResponseError extends Error {
public code!: number;
}
export const request = async <T>(
path: string,
@manix84
manix84 / useInterval.ts
Last active February 8, 2025 18:11
A react hook for setInterval
/**
This code is licensed under the terms of the MIT license
*/
import { useEffect, useRef } from 'react';
export const useInterval = (callback: () => void, delay: number): [() => void] => {
const intervalIdRef = useRef<number | null>(null);
useEffect(() => {
@manix84
manix84 / useTimeout.ts
Last active February 8, 2025 18:11
A react hook for setTimeout
/**
This code is licensed under the terms of the MIT license
*/
import { useEffect, useRef } from 'react';
export const useTimeout = (callback: () => void, delay: number): [() => void] => {
const timeoutIdRef = useRef<number | null>(null);
useEffect(() => {
@manix84
manix84 / inky_frame_telegram.py
Last active February 8, 2025 18:12
A python script for fetching images from Telegram to display on an Inky Frame
# This code is licensed under the terms of the MIT license
import os
import time
import random
import urequests as requests
import upytelegram as telegram
from inky_frame import InkyFrame
from machine import Pin
@manix84
manix84 / useClipboard.ts
Last active July 24, 2024 08:26
A React+Typescript hook for copying different mime types to the clipboard at once.
/**
This code is licensed under the terms of the MIT license
*/
/**
Usage:
const { copyToClipboard } = useClipboard();
copyToClipboard([
{ type: "text/plain", data: "Some String" },
{ type: "text/html", data: "<h1>Some Header</h1>" }