Skip to content

Instantly share code, notes, and snippets.

@Rovsau
Rovsau / GetParsedTable.md
Last active October 10, 2023 04:00
Parse a Spreadsheet range into a table for GitHub, Obsidian, etc.

Parse any spreadsheet range into a table for GitHub, Obsidian, etc.
Expects a header row.

/* Google Apps Script */

/**
 * Select any spreadsheet range, and return a string-parsed table for GitHub, Obsidian, etc. 
 * Note:  Obsidian requires a prefixed empty space for the header row, if the first cell is blank. 
 * @param {Array<Array>} array2d - The source range.
@Rovsau
Rovsau / ExpandGists.md
Last active August 21, 2023 13:32
Make GitHub Gist content fill the width of the browser.

Use a browser-extension to override CSS on a website.
Include the following code under gist.github.com

/* Expand GitHub Gists (Content and Code Blocks) */
div.container-lg.px-3, article {
  max-width: 100%
}

Running AutoHotKey scripts can potentially trigger Anti-Cheat systems.
That means forgetting to stop your scripts before starting a video game could result in consequences.

This script checks if a newly Focused window is either Fullscreen or Blacklisted.
If any of those are true, and the window not Whitelisted, the script will close all other AHK instances, and then itself.

Disclaimer: No guarantees.

/*

This script will essentially multiply the Scroll Amount set in Windows.
It can be changed via Windows Mouse Settings.

;############################################################################
;   Application-specific Scroll Amount, with Scroll Lock for more speed!!!  
;                 an AutoHotKey script made by Rovsau @ GitHub
;############################################################################

#Persistent ; Keep the script running
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.

This is a Prefab Instance Replacer in the form of a MonoBehaviour script. It requires both PrefabInstanceReplacer.cs and GameObjectTypeClassifier.cs

using Rovsau.Unity.Editor.Extensions;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace Rovsau.Unity.Editor.Monos

Untested structure to facilitate using void Reset() for getting components.

  • Interface
  • Implementation - MonoBehaviour
  • Implementation - ScriptableObject
  • Static Methods
  • Abstract MonoBehaviour
  • Abstract ScriptableObject

Interface

This can be used from any other script, and returns with all the Asset GUIDs which were selected in the editor window.
It is an early version. The next one will be able to pass in pre-existing selections.

using System;
using System.Linq;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;

namespace Rovsau.Unity.SceneViewBookmarks
@Rovsau
Rovsau / EnumFlags.md
Last active June 19, 2023 16:55
Readable Enum Flag configuration.

Use bit-shifting with index to avoid hardcoding complex numbers.
The last flag is the Unsigned Bit, also known as the Most Significant Bit, or left-most bit.
Which is what enables a 32bit mask to represent any combination uniquely.

[System.Flags]
public enum MyEnum : byte
{
    None  = 0,         // 00000000  (0 in decimal)
    Flag1 = 1 << 0,    // 00000001  (1 in decimal)
    Flag2 = 1 << 1,    // 00000010  (2 in decimal)
@Rovsau
Rovsau / PostFixedUpdate.md
Last active October 10, 2023 04:06
PostFixedUpdate - Call after FixedUpdate and OnPhysicsXXX

FixedUpdate runs before OnTrigger/Collision/MouseXXX.
PostFixedUpdate runs after all of them.
Which eliminates a 1-frame desync in many solutions.
Drawback: Coroutines generate garbage.

using System.Collections;
using UnityEngine;

/// <summary>