Skip to content

Instantly share code, notes, and snippets.

View Lachee's full-sized avatar
📖
xkcd.com/1421/

Lake Lachee

📖
xkcd.com/1421/
View GitHub Profile
@Lachee
Lachee / FindReferencesAsync.cs
Created May 15, 2020 09:25
Finds References
private static async Task<IEnumerable<ReferencedSymbol>> FindReferencesAsync(UnityEngine.Object asset)
{
var _ = typeof(Microsoft.CodeAnalysis.CSharp.Formatting.CSharpFormattingOptions);
string scriptPath = Path.GetFullPath(UnityEditor.AssetDatabase.GetAssetPath(asset));
//Prepare paths
string folder = Application.dataPath + "/../";
string projectPath = Directory.EnumerateFiles(folder, "*.csproj", SearchOption.TopDirectoryOnly).First();
projectPath = @"D:\Users\Lachee\Documents\Unity Projects\DistanceJam\Assembly-CSharp.csproj";
https://i.lu.je/2020/J3Up2se5qE.mp4 Here is a mp4 of my current issue. The blue is 0,0,1 (left), and the red is 1,0,0 (right). It is spinning clockwise. Here is a topdown representation: https://i.lu.je/2020/mspaint_60BodePItv.png
Why is the right actually on the left? I can fix this by flipping the perspective, but then everything else is flipped and it rotates counter clockwise?
```golang
var rotCubeVerts = []Vector3{
//Vector3{-1, -1, -1}, Vector3{1, -1, -1}, Vector3{1, 1, -1}, Vector3{-1, 1, -1}, // Back Face
Vector3{-1, -1, 1}, Vector3{1, -1, 1}, Vector3{1, 1, 1}, Vector3{-1, 1, 1}, // Front Face
//Vector3{-1, -1, -1}, Vector3{-1, 1, -1}, Vector3{-1, 1, 1}, Vector3{-1, -1, 1}, // Left Face
Vector3{1, -1, -1}, Vector3{1, 1, -1}, Vector3{1, 1, 1}, Vector3{1, -1, 1}, // Right Face
//Vector3{-1, -1, -1}, Vector3{-1, -1, 1}, Vector3{1, -1, 1}, Vector3{1, -1, -1}, // Bottom Face
Vector3{-1, 1, -1}, Vector3{-1, 1, 1}, Vector3{1, 1, 1}, Vector3{1, 1, -1}, //Top Face
@Lachee
Lachee / CyclicList.cs
Created July 20, 2020 09:34
Cyclic Lists that are enumerable and don't contain empty spots.
/// <summary>
/// Cyclic List will never end and cycle back on itself.
/// </summary>
/// <typeparam name="T"></typeparam>
class CyclicList<T> : IEnumerable<T>
{
private T[] _list;
private int _index;
/// <summary>
@Lachee
Lachee / bot.js
Created July 27, 2020 08:19
Basic Bot Template
require('dotenv').config();
const Discord = require('discord.js');
const discord = new Discord.Client();
const ContextConverter = {
convert: async function(prt, type) {
switch (type) {
default: return false;
case 'boolean':
if (prt != "true" && prt != "false" && prt != "yes" && prt != "no") return false;
@Lachee
Lachee / Config.cs
Last active August 20, 2020 05:33
LazyKey is a class that allows for JSON configuration files that utilise separate files for secret tokens. I use this a lot with my bots so I can have a universal configuration, but gitignore .key. It keeps the pattern matching between the Config.cs and the Config.json, by allowing implicit conversion from a string filename. There was the potent…
class Config
{
public string Project { get; set; } = "AProject";
public string Repository { get; set; } = "ARepo";
public string Organization { get; set; } = "https://dev.azure.com/org";
public LazyKey Credentials { get; set; } = "devops.key";
}
@Lachee
Lachee / style.scss
Last active December 9, 2024 17:23
Automatic Dark-Theme switching for GitHub pages.
---
---
@import "{{ site.theme }}";
/**
Custom dark theme for Github Pages, by Lachee.
Put this exactly /assets/css/style.scss in your GitHub Pages root.
*/
@Lachee
Lachee / permutations.js
Created November 28, 2020 04:30
Calculates a permutation of a size x size binary image.
/**
Generate a grid of all permutations of a binary (black and white) NxN pixel image (where n is between 2 and 5).
Then filter it so it removes:
all rotationally symmetric patterns ( rotating it 90 is considered the same patterns )
all non-contiguous patterns ( all the white islands must be connected )
all translationally the same patterns (dont know the term) ( if you move it some distance to the left, its considered the same pattern ) ( i solved this by cropping the image to best fit and then scaling back up )
The result hopefully should be unique tetris pieces
*/
const canvas = document.querySelector('canvas#shapes');
@Lachee
Lachee / keyword.cs
Created February 1, 2021 06:56
I like keywords i guess
public class Why : Span<U>, IDisposable where U : struct
{
const sbyte BECAUSE_YES = 2;
public object Contents { get => (string)this; set { _ = value; } };
public void Dispose() { throw new NotImplementedException(); }
public static explicit operator string(Why y) { return "cause fuck you"; }
}
public async IAsyncEnumerable<T> OhGod<T>(T t) where T : Why
{
@Lachee
Lachee / Example.cs
Last active January 11, 2023 14:12
Unity3D Singleton Class
using UnityEngine;
public class LevelManager : Singleton<LevelManager> {
private void Start() {
Debug.Log("This is a singleton!", LeveLManager.instance);
}
public IEnumerator SoftWaitExample() {
yield return LevelManager.wait;
@Lachee
Lachee / VarData.cs
Last active May 12, 2021 02:23
Variable Data Type for C# and Unity3D
using System;
using System.IO;
#if UNITY_5_3_OR_NEWER
using UnityEngine;
#else
using System.Numerics;
#endif
namespace Lachee.Dynamic