Skip to content

Instantly share code, notes, and snippets.

Avatar

Elie Michel eliemichel

View GitHub Profile
@eliemichel
eliemichel / blender_duplicate_node.py
Last active May 30, 2022
Snippet for reproducing the Shift+D in a node graph editor in Blender
View blender_duplicate_node.py
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
"""
View node_geo_pizza.cc
// [...]
/**
* 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
eliemichel / git_resolve.py
Last active Apr 8, 2022
Resolve conflicted areas of a file in favor of theirs or ours and leave correctly merged areas as is
View git_resolve.py
# This is an automation of https://stackoverflow.com/questions/71783590/git-merge-strategy-option-theirs-for-individual-files
# Example:
# git_resolve.py --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
eliemichel / CMakeLists.txt
Last active Jul 13, 2021
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")
list(APPEND CMAKE_MODULE_PATH "${OpenVDB_INSTALL_DIR}/lib/cmake/OpenVDB")
set(OPENVDB_USE_STATIC_LIBS ON)
find_package(OpenVDB COMPONENTS openvdb REQUIRED)
@eliemichel
eliemichel / TinyTimer.h
Created Jun 7, 2021
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:
@eliemichel
eliemichel / apply_temporal_mapping.jsx
Created Aug 8, 2020
Temporal Stabilization for AfterEffects
View apply_temporal_mapping.jsx
// Select the layer to apply remapping to
// (the rush or any edited version of the rush as long as
// the in/out timings match the original)
var layer = app.project.activeItem.selectedLayers[0];
var timeRemapping = layer.property("ADBE Time Remapping");
// Remove previous keys
while (timeRemapping.numKeys > 0) {
timeRemapping.removeKey(1);
@eliemichel
eliemichel / MOD_pizza.c
Created Sep 14, 2019
Dummy Blender modifier
View MOD_pizza.c
#include "BKE_modifier.h"
#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
static Mesh *pizza_applyModifier(struct ModifierData *md,
const struct ModifierEvalContext *ctx,
struct Mesh *mesh)
{
printf("PIZZA is cooking on data @%p\n", md);
return mesh;
@eliemichel
eliemichel / eliemichel_bezierspline_PythonModule.py
Created Apr 24, 2019
Script of a BezierSpline Houdini Digital Asset
View eliemichel_bezierspline_PythonModule.py
# BezierSpline
# (Houdini Digital Asset Module)
# Shared under the terms of the MIT License
# Copyright (c) 2019 Elie Michel
# This is a wip, expect more docstring eventually
from __future__ import print_function
# Utils
View varint.py
# Varint decoding: https://developers.google.com/protocol-buffers/docs/encoding
import struct
def readVarint(f):
multiplier = 1
value = 0
b = 0xff
while b & 128:
b = struct.unpack('B', f.read(1))[0]
value += multiplier * (b & 127)
@eliemichel
eliemichel / extract_marmoset_archive.py
Last active Oct 16, 2021
Extract the items contained in a Marmoset Viewer's .mview archive file
View extract_marmoset_archive.py
import struct
import os
# Parameter
archive = "vivfox.mview"
def readCString(f):
"""This is the most naive implementation possible, don't use in prod"""
str = ""
c = f.read(1)