Skip to content

Instantly share code, notes, and snippets.

@cmdr2
cmdr2 / sd1-vs-sd2.diff
Created Nov 24, 2022
Diff between https://github.com/CompVis/stable-diffusion (sd1) and https://github.com/Stability-AI/stablediffusion (sd2). Ran `diff -w -x '*.gif' -x '*.png' -x '*.jpg' -x LICENSE -x '*.md' -x '*.git' -r sd1 sd2 > d.txt`
View sd1-vs-sd2.diff
Only in sd2: LICENSE-MODEL
Only in sd2/assets: stable-inpainting
Only in sd2/assets/stable-samples: depth2img
Only in sd2/assets/stable-samples/txt2img: 768
Only in sd2/assets/stable-samples: upscaling
Only in sd1/configs: autoencoder
Only in sd1/configs: latent-diffusion
Only in sd1/configs: retrieval-augmented-diffusion
Only in sd1/configs/stable-diffusion: v1-inference.yaml
Only in sd2/configs/stable-diffusion: v2-inference-v.yaml
View madrang-img-buttons.plugin.js
// contributed by @madrang
PLUGINS['IMAGE_INFO_BUTTONS'].push({ text: 'Double Size (Madrang)', on_click: getStartNewTaskHandler('img2img_X2') })
PLUGINS['IMAGE_INFO_BUTTONS'].push({ text: 'Redo (Madrang)', on_click: getStartNewTaskHandler('img2img') })
function getStartNewTaskHandler(mode) {
return function(reqBody, img) {
const newTaskRequest = getCurrentUserRequest()
switch (mode) {
case 'img2img':
@cmdr2
cmdr2 / user_paths_blender_xr.diff
Created May 5, 2022
Diff for exposing user_path and user_path_other in the Blender XrEventData
View user_paths_blender_xr.diff
diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c
index 6f43afe23fe..52efa1b6653 100644
--- a/source/blender/makesrna/intern/rna_xr.c
+++ b/source/blender/makesrna/intern/rna_xr.c
@@ -1195,6 +1195,50 @@ static int rna_XrEventData_action_length(PointerRNA *ptr)
# endif
}
+static void rna_XrEventData_user_path_get(PointerRNA *ptr, char *r_value)
+{
@cmdr2
cmdr2 / gist:0e4ad366d1fe7b2524511d6bddd15e2a
Last active Dec 5, 2021
Disable discrete GPU on MacBook Pro
View gist:0e4ad366d1fe7b2524511d6bddd15e2a
Follow the steps on http://www.angelofarina.it/DisableDiscrete.htm
if this doesn't work:
`sudo nvram fa4ce28d-b62f-4c99-9cc3-6815686e30f9:gpu-power-prefs=%01%00%00%00`
then try `sudo nvram 000fa4ce-b62f-4c99-9cc3-6815686e30f9:gpu-power-prefs=%01%00%00%00`
Also check if any new NVidia or AMD drivers got created in /System/Library/Extensions, like GeForce* or NVDA* or NVIDIA* or CUDA*, which will need to be moved away
@cmdr2
cmdr2 / Math3d.cs
Created Nov 11, 2021
Useful 3D math functions from the old Unity 3D wiki (which has been shut down). Source: the archived version from July, 2021 at https://web.archive.org/web/20210507045029/https://wiki.unity3d.com/index.php/3d_Math_functions
View Math3d.cs
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
public class Math3d {
private static Transform tempChild = null;
private static Transform tempParent = null;
@cmdr2
cmdr2 / transform-3d-world-local.py
Created Jul 8, 2021
3D world-to-local and local-to-world transform using Python (numpy and transforms3d)
View transform-3d-world-local.py
# pip install transforms3d numpy
import transforms3d as t3d
import numpy as np
scene_transform = {"pos": [0,0,0], "rot": [0,0,0,1], "scale": [1,1,1]}
# https://forum.unity.com/threads/whats-the-math-behind-transform-transformpoint.107401/#post-709765
def local_to_world(p):
v = np.multiply(p, scene_transform["scale"])
View gaussian_random_standard_deviation.js
// returns a gaussian random function with the given mean and stdev.
function gaussian(mean, stdev) {
var y2;
var use_last = false;
return function() {
var y1;
if (use_last) {
y1 = y2;
use_last = false;
} else {
View MarchingCubesExample.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Simple example usage script for MarchingCubes.cs:
// at: https://gist.github.com/cmdr2/b5326aa6fbf3c367747cc5ec31ba831e
//
// Attach to an empty GameObject in the scene
//
// Not optimized, performs poorly! Written for simple readability
@cmdr2
cmdr2 / MarchingCubes.cs
Last active Apr 24, 2022
Reimplementation of a simple Marching Cubes algorithm in C# for Unity. Not for production use, it needs performance improvements. Example script to run this in Unity: https://gist.github.com/cmdr2/b5aea11b9bd5259b9198f4fdc027061c
View MarchingCubes.cs
using System.Collections.Generic;
using UnityEngine;
// Reimplementation of http://paulbourke.net/geometry/polygonise/
// in C# for Unity.
//
// Example script to run this in Unity: https://gist.github.com/cmdr2/b5aea11b9bd5259b9198f4fdc027061c
//
// Note: This uses Unity's Linear Interpolation and Vector3
//
View test.js
<script src="https://cdnjs.cloudflare.com/ajax/libs/processing.js/1.6.0/processing.min.js"></script>
<body>
<script type="application/processing">
void setup(){
size(200, 200);
}
void draw(){
background(64);
ellipse(40, 40, 20, 20);