Skip to content

Instantly share code, notes, and snippets.


Elie Michel eliemichel

View GitHub Profile
eliemichel / webgpu-raii.h
Created May 14, 2023 10:58
An example of RAII wrapper for WebGPU's wgpu::Buffer
View webgpu-raii.h
// Using
#include <webgpu/webgpu.hpp>
namespace raii {
class Buffer {
// Whenever a RAII instance is created, we create an underlying resource
Buffer(wgpu::Device device, const wgpu::BufferDescriptor& bufferDesc)
: m_raw(device.createBuffer(bufferDesc))
eliemichel / save_texture.h
Last active April 22, 2023 13:55
A single-header utility file to save a given WebGPU Texture MIP level into an image
View save_texture.h
#include "stb_image_write.h"
#include <webgpu/webgpu.hpp>
#include <filesystem>
#include <string>
bool saveTexture(const std::filesystem::path path, wgpu::Device device, wgpu::Texture texture, int mipLevel) {
using namespace wgpu;
eliemichel / save_texture_view.h
Last active April 22, 2023 08:47
A single-header utility file to save a WebGPU TextureView into an image
View save_texture_view.h
#include "stb_image_write.h"
#include <webgpu/webgpu.hpp>
#include <filesystem>h
#include <string>
std::filesystem::path resolvePath(int frame) {
std::filesystem::path base = "render/frame" + std::to_string(frame) + ".png";
eliemichel /
Last active October 18, 2022 21:55
Import a module from another text in the same .blend file
def local_import(module_name):
exec('\n'.join([l.body for l in[module_name].lines]))
for k, v in locals().items():
globals()[k] = v
# Example
import bpy
import bmesh
import numpy as np
eliemichel /
Created October 18, 2022 21:46
A minimal profiling module
# Credits 2020-2022 to Élie Michel <>
# Released in Public Domain
# The Software is provided "as is", without warranty of any kind, express or
# implied, including but not limited to the warranties of merchantability,
# fitness for a particular purpose and non-infringement. In no event shall the
# authors or copyright holders be liable for any claim, damages or other
# liability, whether in an action of contract, tort or otherwise, arising
# from, out of or in connection with the software or the use or other dealings
# in the Software.
eliemichel /
Last active May 30, 2022 17:06
Snippet for reproducing the Shift+D in a node graph editor in Blender
import bpy
def duplicate_node(n1, node_group=None, duplicate_links=False):
Duplicate a node (without duplicating its links)
@param n1 The node to duplicate
@param node_group (optional) Group in which the node must be duplicated
@param duplicate_links Whether to keep input links or not
@return the new duplicate node
// [...]
* Create a new Mesh representing a simple pizza (really just a disc with
* a few quads on top of it).
* olive_count is the number of olives topping the pizza
* radius is the radius of the pizza
* base_polys is filled with the range of polygons belonging to the base
* olive_polys is filled with the range of polygons representing the olives
eliemichel /
Last active April 8, 2022 07:55
Resolve conflicted areas of a file in favor of theirs or ours and leave correctly merged areas as is
# This is an automation of
# Example:
# --theirs path/to/some/file
import os
import argparse
from shutil import copyfile
import subprocess
parser = argparse.ArgumentParser(description='Resolve conflicted areas of a file during a git merge')
eliemichel / CMakeLists.txt
Last active July 13, 2021 16:54
Linking issue with OpenVDB - Windows 10, Visual Studio 16 2019, static linking
View CMakeLists.txt
cmake_minimum_required(VERSION 3.7..3.20)
project(MyTest LANGUAGES CXX)
set(OpenVDB_INSTALL_DIR "" CACHE STRING "Directory specified as CMAKE_INSTALL_PREFIX when building OpenVDB")
find_package(OpenVDB COMPONENTS openvdb REQUIRED)
eliemichel / TinyTimer.h
Created June 7, 2021 15:39
A simple C++ timer library
View TinyTimer.h
* A simple timer library.
* Basic usage:
* using TinyTimer::Timer;
* Timer timer;
* // .. do something
* cout << "Something took " << timer.ellapsed() << " seconds" << endl;
* One can also consolidate several timings to measure standard deviation: