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 8, 2024 04:33
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 May 9, 2024 21:44
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
@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
@MightyPork
MightyPork / usb_hid_keys.h
Last active May 13, 2024 09:57
USB HID Keyboard scan codes
/**
* USB HID Keyboard scan codes as per USB spec 1.11
* plus some additional codes
*
* Created by MightyPork, 2016
* Public domain
*
* Adapted from:
* https://source.android.com/devices/input/keyboard-devices.html
*/