Skip to content

Instantly share code, notes, and snippets.

View thygrrr's full-sized avatar
infinite loop

tiger tiger tiger thygrrr

infinite loop
View GitHub Profile
@thygrrr
thygrrr / CameraZoomAndPan.gd
Last active March 15, 2024 19:50
CameraZoomAndPan.gd - Smooth, cursor-centric 2D Zoom for Godot
# SPDX-License-Identifier: Unlicense or CC0
extends Node2D
# Smooth panning and precise zooming for Camera2D
# Usage: This script may be placed on a child node
# of a Camera2D or on a Camera2D itself.
# Suggestion: Change and/or set up the three Input Actions,
# otherwise the mouse will fall back to hard-wired mouse
# buttons and you will miss out on alternative bindings,
# deadzones, and other nice things from the project InputMap.
@thygrrr
thygrrr / MixerGroupSlider.cs
Last active April 16, 2024 10:47
MixerGroupSlider.cs - Unity Implementation of a better-than-logarithmic AudioMixerGroup fader GUI Slider that is more pleasant and intuitive for the users to use, and utilizes the entire value range of its slider. Furthermore, fader values are serialized in PlayerPrefs.
//SPDX-License-Identifier: Unlicense
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
namespace Tiger.Audio
{
[RequireComponent(typeof(Slider))]
@thygrrr
thygrrr / Swizzles.cs
Last active November 24, 2023 14:38
I typed up some Swizzles for y'all!
This file has been truncated, but you can view the full file.
//SPDX-License-Identifier: Unlicense
using UnityEngine;
using Unity.Mathematics;
using System.Runtime.CompilerServices;
// ReSharper disable IdentifierTypo
// ReSharper disable InconsistentNaming
namespace Tiger.Swizzles
@thygrrr
thygrrr / QuaternionUtil.cs
Created October 20, 2023 15:32 — forked from maxattack/QuaternionUtil.cs
Some Helper Methods for Quaternions in Unity3D
using UnityEngine;
/*
Copyright 2016 Max Kaufmann (max.kaufmann@gmail.com)
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 furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
@thygrrr
thygrrr / wordle.py
Last active September 2, 2023 15:28
Wordle Back-Solver, for final result and scores, how many legal games are there?
# SPDX-License-Identifier: Unlicense OR CC0-1.0+
words = [w.lower().strip() for w in open("words.txt", "r").readlines()]
print("loaded", len(words), "Words")
def match(word: str, final: str, score: chr, index: int) -> bool:
return (score == "G" and word[index] == final[index]) or \
(score == "W" and word[index] not in final) or \
(score == "Y" and word[index] != final[index] and word[index] in final)
@thygrrr
thygrrr / Loggers.cs
Last active January 28, 2024 20:49
Loggers.cs - Zero-Boilerplate drop-in replacement logger for Unity in 25 lines of code
//SPDX-License-Identifier: Unlicense OR CC0-1.0+
using System;
using System.Collections.Generic;
using UnityEngine;
using Object = UnityEngine.Object;
// ReSharper disable MemberCanBePrivate.Global
namespace Loggers
{
/// <summary>
@thygrrr
thygrrr / pomodoro.ps1
Last active January 28, 2024 20:49
pomodoro.ps1 - Powershell Pomodoro Timer, locks the workstation when timer expires
# spdx-license-identifier Unlicense
if ($args.count -eq 0)
{
write-host "Pomodoro Timer that locks the workstation (screen) when done."
write-host "Usage: pomodoro.ps1 <minutes> ['activity']"
write-host "Example: pomodoro.ps1 5 try out new script"
Exit
}
# Select default activity if none is specified, otherwise concat all optional arguments
@thygrrr
thygrrr / ControlSystem.cs
Last active February 5, 2022 12:43
A ECS system where a physical object can "cut" through a turn and glide like a ship or a bird.
using Jovian.ECS.Components;
using Jovian.ECS.Components.Space;
using Jovian.ECS.Components.Vessels;
using Jovian.ECS.Systems.Physics;
using Unity.Burst;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Physics.Systems;
from typing import Collection
def count_bits(diagnostics: Collection[str]) -> (list[int], int):
bit_counts = []
for number in diagnostics:
for bit_index, binary_digit in enumerate(number):
while bit_index >= len(bit_counts):
bit_counts.append(0)
@thygrrr
thygrrr / ListExtensions.cs
Last active April 28, 2021 23:39
Array and List Extensions for Unity
using System;
using System.Collections.Generic;
using Random = UnityEngine.Random;
namespace Tiger.Util
{
public static class ListExtensions
{
/// <summary>Returns a random element from the list</summary>