Skip to content

Instantly share code, notes, and snippets.

@mdiep
mdiep / diff-values.swift
Created February 4, 2020 13:02
Diff values with Mirror and AnyHashable
import Foundation
// Diff values for better test assertions.
//
// Enums and collections left as an exercise for the reader.
// A difference between two values
struct Difference: CustomStringConvertible {
let path: String
let actual: String

Dirtywave M8 Shortcuts

Extracted from the resources page at dirtywave.com.

Global Key Shortcuts

  • [DIRECTION] Move the cursor on the screen.
  • [SHIFT]+[DIRECTION] Navigate between Views
  • [EDIT] Start editing a value; also functions as a “YES” or “ENTER”
@benhoyt
benhoyt / markov.py
Created November 11, 2023 15:45
Generate text from an input using a simple Markov chain generator
import collections, random, sys, textwrap
# Build possibles table indexed by pair of prefix words (w1, w2)
w1 = w2 = ''
possibles = collections.defaultdict(list)
for line in sys.stdin:
for word in line.split():
possibles[w1, w2].append(word)
w1, w2 = w2, word
@davideicardi
davideicardi / TimerAsync.cs
Created February 19, 2018 21:34
A Timer that execute an async callback at the specified interval
/// <summary>
/// A Timer that execute an async callback after a due time and repeating it after a period (interval).
/// Callback is a non reentrant timer (ie. callbacks never overlaps). Dispose method wait for the current callback to finish.
/// Timer can be cancelled using a CancellationToken or by calling StopAsync or by calling Dispose.
/// Exception inside callbacks are ignored and just traced.
/// Callback is invoked at each interval (period) after the end of the previous invocation.
/// </summary>
public sealed class TimerAsync : IDisposable
{
private readonly Func<CancellationToken, Task> _callback;
@fredrikaverpil
fredrikaverpil / get_set_values.py
Last active May 20, 2024 20:31
Get and set knob values #nuke
# Get all nodes of type Read
readnodes = nuke.allNodes('Read')
for readnode in readnodes:
print readnode
# List all knobs for selected node
print( nuke.toNode('Read1') )
# List all knobs for specific node
print( nuke.selectedNode() )
@BigRoy
BigRoy / alembic_has_any_shapes.py
Last active May 20, 2024 20:31
Python script using Alembic api to detect whether an .abc file contains any shapes.
import alembic
def any_shapes_in_alembic(filename):
"""Return whether Alembic file contains any shape/geometry.
Arguments:
filename (str): Full path to Alembic archive to read.
Returns:
bool: Whether Alembic file contains geometry.
@Flafla2
Flafla2 / Perlin_Tiled.cs
Last active May 20, 2024 20:31
A slightly modified implementation of Ken Perlin's improved noise that allows for tiling the noise arbitrarily.
public class Perlin {
public int repeat;
public Perlin(int repeat = -1) {
this.repeat = repeat;
}
public double OctavePerlin(double x, double y, double z, int octaves, double persistence) {
double total = 0;
@Kif11
Kif11 / align_to_normal.vex
Last active May 20, 2024 20:31
Rotate flat geometry to X/Z plane. Houdini VEX.
// Align object to target vector base on selected normal
// Useful when object has some weird orientation baked
// in the mesh and you wan to straighten it up.
// Point with normal from second wrangler input to align
vector from = point(1, 'N', 0);
// Allign "from" normal to the following vector
vector to = {0,1,0};
@nicobrx
nicobrx / to_util
Last active May 20, 2024 20:31
Google Apps Script utility functions for working with 2D arrays in Sheets/tabs, plus a few other miscellanea. The 2D functions depend on the first row of a tab being column headers and each row below the first row having the same number of columns as the first row.
/*
updated 2018-04-28
source lives here: https://gist.github.com/nicobrx/2ecd6fc9ca733dcd883afebba5cf200e
standalone script ID for use as a library: 1gZ78JObyrYiH0njoZ86fQ2NgMwavUgiXVhRDrIFetPZL256e31PSNiHq
Functions included here:
Sheets data array and object functions
objectifySheet(sheet,propertyNames,newPropertyNames) - Takes a sheet with a header row and converts it into an array of objects
arrayFromSheet(sheet,propertyNames,newPropertyNames) - creates an array from a sheet, can specify column headers
@werediver
werediver / resample_rlen.vex
Created October 10, 2020 15:22
Houdini VEX code to resample a (two point) curve into segments of random length (with restrictions)
// Resample into segments of random length
// Run over primitives
float seed = chf("seed");
float seg_len_min = chi("seg_len_min");
float seg_len_max = chi("seg_len_max");
float seg_padding = chf("padding");
if (seg_len_min <= 0 || seg_len_max < seg_len_min || seg_padding < 0) {
error("Make sure 0 < seg_len_min <= seg_len_max and 0 <= seg_padding");