Skip to content

Instantly share code, notes, and snippets.

View PeterHindes's full-sized avatar
💭
Learning Python

Peter Hindes PeterHindes

💭
Learning Python
View GitHub Profile
@PeterHindes
PeterHindes / image-separator.py
Created December 15, 2023 20:24
PNG Image Separator/Island Isolator (useful for after effects animating png logos)
import cv2
import numpy as np
def save_components(image_path):
# Load the image with alpha channel
img = cv2.imread(image_path, cv2.IMREAD_UNCHANGED)
# Create a binary image where 0 indicates transparent pixels
_, alpha_bin = cv2.threshold(img[:,:,3], 0, 255, cv2.THRESH_BINARY)
@PeterHindes
PeterHindes / README.md
Created August 24, 2023 23:30
Cloudflare Router

Cloudflare simple router

Just put the method and path in a string mapped to a function in the routes constant and you can have any function run when that path is fetched.

The provided file has some example functions imported from another file.

@PeterHindes
PeterHindes / README.md
Last active January 28, 2024 20:45
Cloudflare Workers JWT Functions

Avalible Functions

generateKeyPair

Generates a public and private key

keyToString

Converts a key object into a string

stringToPrivateKey

converts a private key back from a string

stringToPublicKey

same but for public keys

sign

@PeterHindes
PeterHindes / fixit.sh
Created May 21, 2022 16:23
How to fix docker volumes permission denied on fedora and other selinux distros
setenforce 0
@PeterHindes
PeterHindes / docker-compose.yaml
Created May 21, 2022 06:10
Docker Compose With Haproxy
version : '3'
services:
ha:
image: haproxy
ports:
- "8080:8080"
- "8081:8081"
volumes:
- ./haproxy:/usr/local/etc/haproxy
@PeterHindes
PeterHindes / index.js
Last active May 25, 2022 22:28
Nodejs websockets boilerplate
const async = require('async')
,fs = require('fs')
,http = require('http')
,ws = require('websocket')
;
const APPID = process.env.APPID;
let connections = [];
const WebSocketServer = ws.server
@PeterHindes
PeterHindes / handle_ctrl_c_example.py
Last active February 15, 2022 18:23
Handle a user wanting to quit a looping terminal program.
import signal
import sys
import time
def signal_handler(signal, frame):
print("Wasting your time...")
time.sleep(3)
print("Goodbye")
raise SystemExit
signal.signal(signal.SIGINT, signal_handler)
@PeterHindes
PeterHindes / Consumer.sol
Created February 13, 2022 18:23
Solidity array of strings in another contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
contract SVG1 {
string[] public svg;
}
contract User is SVG1 {
SVG1 s;
constructor (address _provider) {
@PeterHindes
PeterHindes / fix_it.sh
Created May 25, 2018 23:22
Fix Battle Block Theater Error That The Devs Refuse To
#!/usr/bin/env bash
FILE=BattleBlockTheater
MD5_PRE=436e91811d8a38de1918991969347b3d
MD5_POST=71eb6519233b21d85c858b39f2b4871f
OFFSET=0x24f2b9
PAYLOAD='\x90\x90'
function getMD5()
{