Skip to content

Instantly share code, notes, and snippets.

@Matt54
Matt54 / MarchingCubesColorBlobParams.h
Last active November 4, 2025 16:41
RealityKit Color-Blending Metaballs (Metal + LowLevelMesh + Marching Cubes)
#ifndef MarchingCubesColorBlobParams_h
#define MarchingCubesColorBlobParams_h
#include <simd/simd.h>
typedef struct {
simd_float3 center;
float radius;
simd_float3 color;
float _pad;
@TheoBoyer
TheoBoyer / gist:4800465e75f392e4c68162253e8e8531
Created August 26, 2025 17:02
Attention sink using sdpa kernels from pytorch
import math
import torch
from typing import Optional, Tuple
# Reference implementation
def sdpa_with_sink(q: torch.Tensor, k: torch.Tensor, v: torch.Tensor, s: torch.Tensor) -> torch.Tensor:
logits = torch.matmul(q, k.transpose(-2, -1)) / (D ** 0.5) # [B, H, S, S]
exp_logits = torch.exp(logits) # [B, H, S, S]
mass = exp_logits.sum(dim=-1, keepdim=True) + s.exp()[:, None, None] # [B, H, S, 1]
@Chillee
Chillee / tv_layout_viz.py
Last active September 19, 2025 09:51
Cutlass Thread-Value Layout Visualizer
import math
import cutlass.cute as cute
import cutlass
def visualize_tv_layout(
tiler_mn: tuple[int, int],
tv_layout, # (((thr_shape),(val_shape)),
# ((thr_stride),(val_stride)))
*,
font_size: int = 10,
from functools import partial
import jax
import jax.numpy as jnp
import optax
def poly(x: jnp.ndarray, w: jnp.ndarray):
assert w.shape == (3,)
w = w.astype(jnp.float32)
@smbss1
smbss1 / ToonTerrain.cginc
Created January 24, 2023 01:40 — forked from probablyspoonie/ToonTerrain.cginc
Toon Terrain Tutorial
// Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
// Edits by Glynn Taylor. MIT license
// Includes code for splitmap by https://twitter.com/adamgryu and triplanar mapping by https://github.com/keijiro. MIT License
#ifndef TERRAIN_SPLATMAP_COMMON_CGINC_INCLUDED
#define TERRAIN_SPLATMAP_COMMON_CGINC_INCLUDED
struct Input
{
float3 localNormal : TEXCOORD0;
@Cyanilux
Cyanilux / SGTessellation.hlsl
Last active March 24, 2025 06:57
Allows you to inject tessellation into SG & URP, but hacky / can be difficult to work with. Unsure if the same method can work for HDRP. Also see : https://twitter.com/Cyanilux/status/1388158860574314498. Tested in v10. Could definitely break at some point, use at your own risk :)
// @Cyanilux
// Note : Also requires setting up "_TessellationUniform" Float in Blackboard
/*
Allows you to inject tessellation into SG & URP, but hacky / can be difficult to work with.
While this works, it's maybe not as useful as you might think. I believe any vertex displacement would need to be
taken out of the graph and moved into the domain function below (since tessellation still runs after vertex shader).
I thought about using the VertexDescriptionFunction from the generated code, but sadly that's generated after the injection point
so can't be called as it's undeclared at that point.
@mwufi
mwufi / install_docker_in_colab.sh
Last active October 2, 2025 17:59
Install Docker in Google Colab!
# First let's update all the packages to the latest ones with the following command
sudo apt update -qq
# Now we want to install some prerequisite packages which will let us use HTTPS over apt
sudo apt install apt-transport-https ca-certificates curl software-properties-common -qq
# After that we will add the GPG key for the official Docker repository to the system
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# We will add the Docker repository to our APT sources
import argparse
import json
predefined_struct = {
"UnityEngine_Vector3_o" : [("float","x"),("float","y"),("float","z")]
}
def extract_class_methods(methods_informations, clazz):
"""
We check if the signature start with the class we want to hook, if so
function bypassCheckProperties() {
/*
* Function used to bypass common checks to
* Android OS properties
* Bypass the props checking from this git : https://github.com/strazzere/anti-emulator
*
*/
const SystemProperties = Java.use('android.os.SystemProperties')
const String = Java.use('java.lang.String')
const Properties = {
@kylemcdonald
kylemcdonald / pytorch_setup.sh
Created August 29, 2018 02:48
Install CUDA 9.2, cuDNN 7.2.1, Anaconda and PyTorch on Ubuntu 16.04.
# tested on AWS p2.xlarge August 29, 2018
# install CUDA
sudo apt-get update && sudo apt-get install wget -y --no-install-recommends
CUDA_URL="https://developer.nvidia.com/compute/cuda/9.2/Prod2/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.148-1_amd64"
wget -c ${CUDA_URL} -O cuda.deb
sudo dpkg --install cuda.deb
sudo apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub
sudo apt-get update
sudo apt-get install -y cuda