Skip to content

Instantly share code, notes, and snippets.

View JimmyCushnie's full-sized avatar

Jimmy Cushnie JimmyCushnie

View GitHub Profile
@JimmyCushnie
JimmyCushnie / FocusLogger.cs
Last active August 14, 2025 08:44
FocusLogger for BenchmarkDotNet
using System.Collections.Frozen;
using System.Text.RegularExpressions;
using BenchmarkDotNet.Loggers;
/// <summary>
/// Custom logger for printing BenchmarkDotNet output to console.
/// Prints much less output than the default <see cref="ConsoleLogger"/>, so you can focus on the most important parts of the output.
/// </summary>
public partial class FocusLogger : ILogger
{
@JimmyCushnie
JimmyCushnie / TikTokTimeTaker.cs
Created August 17, 2021 13:53
Extract a timestamp from a TikTok ID.
class Program
{
static void Main()
{
Console.WriteLine("Enter tiktok ID");
ulong id = ulong.Parse(Console.ReadLine());
ulong shifted = id >> 32;
var date = DateTime.UnixEpoch.AddSeconds(shifted);

Blotter File Format - v7

The Blotter File Format, successor to the format known as ".tung files", is a system for storing the components and wires of a Logic World world. It is used for both full world saves as well as partial worlds (the data structure used by Subassemblies), but there are slight differences between the two.

File types

  • World files:
    • Represent a full, playable world space
    • May have zero or more root components at different positions/rotations in the world
  • Use .logicworld file extension
@JimmyCushnie
JimmyCushnie / TypeStrings.cs
Created September 14, 2020 15:01
Turn C# type variables into and out of strings that look like C# code.
// These are methods for turning C# type variables into and out of strings that look like C# code.
// It has full support for generics (including unbound generics) and arrays of all dimensions.
// Examples of strings generated/parsed:
// System.Int32
// System.Collections.Generic.List<System.Int32>
// System.Collections.Generic.List<>
// System.Int32[]
// System.Int32[,,]
// System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.List<System.Int32[,,]>>
@JimmyCushnie
JimmyCushnie / UnityGraphicsBullshit.cs
Last active August 4, 2025 15:41
Exposes some Unity URP graphics settings that are (for some stupid fucking bullshit reason) private.
using System.Reflection;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using ShadowResolution = UnityEngine.Rendering.Universal.ShadowResolution;
/// <summary>
/// Enables getting/setting URP graphics settings properties that don't have built-in getters and setters.
@JimmyCushnie
JimmyCushnie / TwoWayDictionary.cs
Last active May 12, 2019 07:20
Two way dictionary
// This is a version of System.Collections.Generic.Dictionary<TKey, TValue> where both types can act as keys and values.
// For example, you could have a TwoWayDictionary<string, int>. This would be able to look up ints by string, but
// it would ALSO be able to look up strings by int.
// All the code in this class is O(1) except for the seeded constructors.
// you are free to use and modify this code for anything, full licence terms at the end of the file.
using System.Collections.Generic;
using System.Linq;
@JimmyCushnie
JimmyCushnie / QuaternionBullshit.cs
Created May 9, 2019 08:39
Convert Euler angles to quaternions and quaternions to Euler angles
Vector3 QuaternionToEuler(Quaternion q)
{
Vector3 euler;
// if the input quaternion is normalized, this is exactly one. Otherwise, this acts as a correction factor for the quaternion's not-normalizedness
float unit = (q.x * q.x) + (q.y * q.y) + (q.z * q.z) + (q.w * q.w);
// this will have a magnitude of 0.5 or greater if and only if this is a singularity case
float test = q.x * q.w - q.y * q.z;