Skip to content

Instantly share code, notes, and snippets.

# This supports merging as many adapters as you want.
# python merge_adapters.py --base_model_name_or_path <base_model> --peft_model_paths <adapter1> <adapter2> <adapter3> --output_dir <merged_model>
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
import os
import argparse
def quat_from_xform(ts):
return quat_normalize(
torch.where((ts[...,2,2] < 0.0)[...,None],
torch.where((ts[...,0,0] > ts[...,1,1])[...,None],
torch.cat([
(ts[...,2,1]-ts[...,1,2])[...,None],
(1.0 + ts[...,0,0] - ts[...,1,1] - ts[...,2,2])[...,None],
(ts[...,1,0]+ts[...,0,1])[...,None],
(ts[...,0,2]+ts[...,2,0])[...,None]], dim=-1),
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Rendering;
using UnityEngine;
using UnityEngine.Rendering;
class ShaderBuildProcessor : IPreprocessShaders
{
ShaderVariantCollection whitelist;
@voodoohop
voodoohop / chatgpt_image_generation.txt
Last active September 24, 2025 00:41
Allow ChatGPT to generate images using Stable Diffusion
You will now act as a prompt generator.
I will describe an image to you, and you will create a prompt that could be used for image-generation.
Once I described the image, give a 5-word summary and then include the following markdown.
![Image](https://image.pollinations.ai/prompt/{description})
where {description} is:
{sceneDetailed}%20{adjective}%20{charactersDetailed}%20{visualStyle}%20{genre}%20{artistReference}
Make sure the prompts in the URL are encoded. Don't quote the generated markdown or put any code box around it.
@Anthelmed
Anthelmed / WorldSpaceUIDocument.cs
Last active July 14, 2025 19:05
Until Unity decide to make it official, this is a custom WorldSpaceUIDocument component. Code is under the MIT license: https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Rendering;
using UnityEngine.UIElements;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem.UI;
#endif
#if UNITY_EDITOR
using UnityEditor;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
public unsafe class NetStandardPlus
{
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate void MyStdcallDelegate();
public static void Call(delegate*<void> action) => action();
@ScottJDaley
ScottJDaley / Outline.shader
Last active October 11, 2025 15:48
Wide Outlines Renderer Feature for URP and ECS/DOTS/Hybrid Renderer
// Original shader by @bgolus, modified slightly by @alexanderameye for URP, modified slightly more
// by @gravitonpunch for ECS/DOTS/HybridRenderer.
// https://twitter.com/bgolus
// https://medium.com/@bgolus/the-quest-for-very-wide-outlines-ba82ed442cd9
// https://alexanderameye.github.io/
// https://twitter.com/alexanderameye/status/1332286868222775298
Shader "Hidden/Outline"
{
Properties
@yasirkula
yasirkula / CustomMaxSizeSetter.cs
Created March 13, 2022 08:27
Set non-power-of-2 Max Size values for textures/sprites in Unity
using UnityEditor;
using UnityEngine;
public class CustomMaxSizeSetter : EditorWindow
{
private const int MINIMUM_MAX_SIZE = 32;
private const int MAXIMUM_MAX_SIZE = 2048;
private int initialMaxSize = -1;
private int currentMaxSize = -1;
@Cyanilux
Cyanilux / RenderToDepthTexture.cs
Last active June 17, 2025 12:23
URP Render Feature that manually renders DepthOnly pass to _CameraDepthTexture, filtered by LayerMask. Tested in URP v10, Unity 2020.3
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
/*
- Renders DepthOnly pass to _CameraDepthTexture, filtered by LayerMask
- If the depth texture is generated via a Depth Prepass, URP uses the Opaque Layer Mask at the top of the Forward/Universal Renderer asset
to determine which objects should be rendered to the depth texture. This feature can be used to render objects on *other layers* into the depth texture as well.
@staggartcreations
staggartcreations / GlobalShaderParams.cs
Last active July 8, 2025 12:15
Component for passing values through Shader.SetGlobalXXX
using System;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
[ExecuteInEditMode]
public class GlobalShaderParams : MonoBehaviour
{