Skip to content

Instantly share code, notes, and snippets.

@unitycoder
unitycoder / CustomThumbnail.cs
Created April 7, 2024 09:18
Save Thumbnails for Scenes (unity editor script)
using System.IO;
using UnityEditor;
using UnityEngine;
namespace UnityLibrary
{
[CustomEditor(typeof(SceneAsset))]
public class CustomThumbnail : Editor
{
public override bool HasPreviewGUI() => true;
#%% <- this is vscode stuff, this will run on the command line but plots might come out weird
import numpy as np
u32 = np.uint32
i32 = np.int32
def golden_ratio_sequence(i: u32) -> u32:
return u32(i) * u32(2654435769) # 0.614... in 0.32 fixed point
def reverse_bits32(x: u32) -> u32:
x = u32(x)
@scivision
scivision / Readme.md
Last active January 17, 2025 21:45
Intel oneAPI GitHub Actions with MKL and MPI (C, C++, Fortran) and CMake

GitHub Actions Intel oneAPI without caching

Unlike cached approach, this is simpler but takes much longer to setup on each run.

@yasirkula
yasirkula / BatchExtractMaterials.cs
Last active February 8, 2025 00:16
Batch extract materials from 3D model assets in Unity
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.IO;
public class BatchExtractMaterials : EditorWindow
{
private enum ExtractMode { Extract = 0, Remap = 1, Ignore = 2 };
[System.Serializable]
@easyaspi314
easyaspi314 / change_case_simd.c
Created February 6, 2019 06:06
SIMD functions to apply toupper/tolower to each character in a string
/* Created by easyaspi314. Released into the public domain. */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __SSE2__
#include <immintrin.h>
@imneme
imneme / xoshiro.hpp
Created July 4, 2018 04:23
A C++ implementation of a family of Xoshiro generators
#ifndef XOSHIRO_HPP_INCLUDED
#define XOSHIRO_HPP_INCLUDED 1
/*
* A C++ implementation of a family of Xoshiro generators.
*
* See:
* https://arxiv.org/abs/1805.01407
* http://xoshiro.di.unimi.it/xoshiro256plus.c
* http://xoshiro.di.unimi.it/xoshiro256starstar.c
@iwanders
iwanders / compile_time_crc.hpp
Last active February 2, 2025 14:02
C++ Compile Time CRC32
/*
The MIT License (MIT)
Copyright (c) 2018 Ivor Wanders
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@kajott
kajott / image_predict.c
Created May 4, 2018 07:14
channel separation, color decorrelation, and prediction filtering as preprocessing for lossless RGB image compression
#if 0 // self-compiling code
gcc -std=c99 -Wall -Wextra -pedantic -g -O3 -march=native $0 -o image_predict || exit 1
exec ./image_predict $*
#endif
// Example code for pre-filtering operations that transform RGB images into
// representations that are better suited for lossless compression
// (color channel separation and decorrelation, pixel prediction).
// Takes a .ppm file as an input and generates multiple files in the form
@imneme
imneme / xorshift.hpp
Last active February 15, 2023 17:47
A Family of Truncated XorShift* PRNGs
#ifndef XORSHIFT_HPP_INCLUDED
#define XORSHIFT_HPP_INCLUDED 1
/*
* A C++ implementation of a family of truncated XorShift* generators.
*
* The MIT License (MIT)
*
* Copyright (c) 2017-19 Melissa E. O'Neill
*
Shader "Custom/Template"
{
Properties
{
_MainTex ("Albedo (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 80