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the site-packages of the current python environment into a zip file
If you have any wheels at `$(pwd)/wheels`, those will be used instead of
of the locally installed packages. For instance, if my pwd looked like
wheels/
|-- numpy-1.11.2-cp27-cp27mu-manylinux1_x86_64.whl
# this scripts installs necessary requirements and launches main program in webui.py
import subprocess
import os
import sys
import importlib.util
import shlex
import platform
import argparse
import json
import time
@d8ahazard
d8ahazard / colorswarm_all.py
Created December 4, 2022 16:57
Home Assistant PyScript - ColorSwarm For ALl
"""
A collection of lighting effects that runs asynchronously on Philips Hue rooms/groups.
Pyscript must be configured to expose the "hass" global variable and allow all imports
so that we can access the Hue bridge configs and entity registry.
"""
import heapq
import logging
import random
import time
@d8ahazard
d8ahazard / setup_wsl.sh
Last active October 24, 2022 07:49
Setup WSL For Dreambooth Stable Diffusion (Ubuntu)
#!/bin/bash
sudo apt-get update
sudo apt-get -y upgrade
# Get git
sudo apt-get -y install git
# install conda (if not already done)
if [ ! -f "./Anaconda3-2022.10-Linux-x86_64.sh" ]; then
wget https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64.sh
@d8ahazard
d8ahazard / plex_cleanup.py
Last active June 22, 2023 17:49
A utility for cleaning Plex collections and identifying orphaned media.
import os
import pathlib
import sqlite3
target_path = ""
movie_list = []
tv_list = []
collection_list = []
@d8ahazard
d8ahazard / SectorCreator.cs
Created August 27, 2019 12:32
A quickie script to take all items in a SECTR terrain chunk and add them as children of that chunk.
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
[ExecuteInEditMode]
public class SectorCreator : MonoBehaviour
{
@d8ahazard
d8ahazard / index.php
Last active December 26, 2018 02:52
PlexProfileScraper
<?php
$files = glob("./profiles/*.xml");
$profiles = [];
$types = [];
$names = [];
foreach($files as $file) {
$data = new SimpleXMLElement(file_get_contents($file));
$flat = json_decode(json_encode($data), true);
$name = $flat['@attributes']['name'];
$dpTypes = [];
@d8ahazard
d8ahazard / swagger2Php.php
Last active February 29, 2024 07:18
Auto-generate PHP class from swagger documentation...
<?php
// You need to have guzzleHttp installed, and require the vendor path here...
header('content-type:text/plain');
$url = $_GET['url'];
$swaggerApi = json_decode(file_get_contents("$url"), true);
$outFile = pathinfo($url)['filename'] . ".php";
$paths = $swaggerApi['paths'];
$defs = $swaggerApi['definitions'];