Skip to content

Instantly share code, notes, and snippets.

View CodeZombie's full-sized avatar
🌵

Jeremy Clark CodeZombie

🌵
View GitHub Profile
@CodeZombie
CodeZombie / instructions.md
Last active February 6, 2024 20:15
CozyLife Smart Bulb with Home Assistant

How To: Set Up your Stupid Fucking 4 Dollar "Cozy-Life" Wi-Fi Smart Bulb with Home Assistant with Minimal Hair-Pulling

Installing Home Assistant with Docker Compose

This parts simple enough, but requires some adjusting of the official instructions to get working. Most instructions online tell you that your docker-compose.yml file needs to have a network_mode: host in there. I dunno about that! Works fine for me without that, so we're going to not.

version: '3'
services:
 homeassistant:
@CodeZombie
CodeZombie / m8_headless_gpio_audio_out
Created December 12, 2023 05:02
M8 headless GPIO Audio Out
The M8 Headless is so cool!
Except that it wants to send audio over USB! That shit sucks! Especially on android where it doesn't work at all!
Solution: Hook a PCM5102 up to the Teensy 4.1 running m8 headless! It actually works!
Pins:
PCM5012 -> TEENSY
SCK -> 23
BCK -> 21
DIN -> 7
@CodeZombie
CodeZombie / supersearch.py
Created December 1, 2023 18:00
Given a huge directory a files, this script will search the content of each file, and copy it to a new directory if it contains a substring. Threaded.
import os
import threading
import shutil
from collections import namedtuple
ThreadWithData = namedtuple('thread', 'thread, filecount')
# Constants
MAX_THREADS = 12
FILES_PER_THREAD = 500
@CodeZombie
CodeZombie / fastboot_instructions.txt
Created September 3, 2023 20:13
How to fastboot into the fucking redmi note 7
I don't think anyone, at any point, actually wrote this shit down, so here I am, doing God's work:
1. Download `http://bigota.d.miui.com/tools/xiaomi_usb_driver.rar`
2. Extract.
3. Connect your phone to the pc, boot into fastboot mode.
4. In Device Manager, select the device, select `update driver`
5. Choose `browse my computer for drivers` and select the xiaomi usb driver folder.
6. It will install something, but it'll be the wrong one.
7. Select Update Driver again, choose `browse my computer for drivers`, but this time click `let me pick from a list of available drivers`
8. Select the `bootloader` option.
@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.