Skip to content

Instantly share code, notes, and snippets.

# Script for converting a HF Diffusers saved pipeline to a ControlNet checkpoint.
# *Only* converts the ControlNet.
# Does not convert optimizer state or any other thing.
import argparse
import os.path as osp
import re
import torch
from safetensors.torch import load_file, save_file
@neggles
neggles / Set-VGpuEternalTrial.ps1
Last active May 12, 2024 00:34
Sets nVidia vGPU unlicensed state timeout to 24 hours and adds a daily scheduled task to restart the GPU drivers and reset the clock.
<#
.SYNOPSIS
Set vGPU VM instance into eternal trial.
.DESCRIPTION
Configures a Windows vGPU client for a 24-hour trial period and automatic daily driver restarts.
.EXAMPLE
Set-VGpuEternalTrial -RestartTime 2AM
.EXAMPLE
Set-VGpuEternalTrial -RestartTime 3AM -Filter '*GRID*'
.INPUTS
@koshatul
koshatul / README.md
Last active June 12, 2024 14:51
use Apple Keychain to store GPG Passphrases

gpg-agent setup

Need to setup gpg-agent first, on OSX I use keychain (it also does ssh-agent)

$ brew info keychain
keychain: stable 2.8.5
User-friendly front-end to ssh-agent(1)
https://www.funtoo.org/Keychain
/usr/local/Cellar/keychain/2.8.5 (7 files, 108.5KB) *

Disable Device Enrollment Notification on Mac.md

Restart the Mac in Recovery Mode by holding Comment-R during restart

Open Terminal in the recovery screen and type

csrutil disable
@CrackerJackMack
CrackerJackMack / 01_README.md
Created June 4, 2017 05:33
systemd # workaround

This is my take on a systemd#2741 work-around. The lack of native namespace joining makes it so you have to do a dance with systemd's version of private namespaces and iproute2's version. The portal_network.sh is my rendition of iproute2.
Credit to ian-kelling's code and comment in the systemd issue that inspired me to research this further. Looking at iproute2's source the bash script should be identical, including the private mount and bind mounts. This level of compatibility gives the administrator the ability to use ip -n portal ... for any subsequent commands.

Files are dash separated due to this being a gist (slashes aren't allowed). PLace the files in the correct locations then run the following:

  1. systemctl enable portal.target portal.network.service whatever.service
  2. systemctl restart systemd-networkd # if using the vlan files and such
@simonw
simonw / recover_source_code.md
Last active May 30, 2024 00:39
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
/**
* For Google Voice
* @Author zbinlin <zbinlin@outlook.com>
*/
var sleep = delay => new Promise(resolve => setTimeout(resolve, delay));
var composeClick = function x(btn) {
var rect = btn.getBoundingClientRect();
var x = Math.floor(rect.clientX + rect.width * Math.random());
var y = Math.floor(rect.clientY + rect.height * Math.random());
@dtaylor84
dtaylor84 / gpg-agent-forward.sh
Last active May 15, 2017 07:10
Cygwin GPG Agent Forwarding Script (for use with Gpg4Win 3, requires openssh and ssh-pageant)
#!/bin/bash -e
remote="$1@$2"
echo -ne '\e]0;wait... '"$remote"'\a'
eval $(/usr/bin/ssh-pageant -r -a "/tmp/.ssh-pageant-$USERNAME")
localdir="$(cygpath -u "$APPDATA")/gnupg"
extrasock="$localdir/S.gpg-agent.extra" # file containing "PORT\nNONCE"
rdir='$HOME/.gnupg' # remote prefix
rinsock="$rdir/S.gpg-agent" # listen on this socket on server
@igv
igv / KrigBilateral.glsl
Last active June 14, 2024 21:42
Good test pattern: https://www.rtings.com/images/test-materials/2017/chroma-444.png (Compress it with any lossy codec first, for example jpeg. You can do it with mpv, only add screenshot-jpeg-source-chroma=no to mpv.conf). Usage: glsl-shader="~~/KrigBilateral.glsl"
// KrigBilateral by Shiandow
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3.0 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU