Skip to content

Instantly share code, notes, and snippets.

View MisterKidX's full-sized avatar

Dor Ben Dor MisterKidX

View GitHub Profile
using System;
using System.IO;
using System.Reflection;
using System.Text;
using Unity.Entities;
using UnityEditor;
/// <summary>
/// will create a new authring script based on an IComponentData
/// </summary>
@MisterKidX
MisterKidX / nggyu.cs
Created February 9, 2023 11:40
Try this beep sound
Console.Beep(523, 300);
Console.Beep(587, 300);
Console.Beep(659, 300);
Console.Beep(698, 300);
Console.Beep(587, 900);
Console.Beep(783, 300);
Console.Beep(880, 300);
Console.Beep(783, 1200);
Console.Beep(523, 150);
Console.Beep(587, 150);
@MisterKidX
MisterKidX / sevenNationArmyBeeps
Created February 9, 2023 07:56
Seven Nation Army - Console.Beeps :)
// Orioginally by maybe_an_username
// https://www.reddit.com/r/PowerShell/comments/q8l24k/some_powershell_beep/
Console.Beep(196, 1200);
Console.Beep(196, 300);
Console.Beep(220, 400);
Console.Beep(196, 400);
Console.Beep(174, 300);
Console.Beep(155, 1000);
Console.Beep(146, 1000);
@MisterKidX
MisterKidX / takeOnMe
Created February 9, 2023 07:52
Aha - Take on Me - Console.Beeps :)
// Originally by Shensd
// https://gist.github.com/Shensd/01342e2f399de4dca2ca87b36059ba0a
Console.Beep(369, 200);
Console.Beep(369, 200);
Console.Beep(369, 200);
Console.Beep(293, 300);
Console.Beep(246, 200);
Console.Beep(329, 250);
Console.Beep(329, 200);
Scene physicsScene = new Scene();
var go1 = physicsScene.Instantiate();
var rb1 = new Rigidbody(go1) { Gravity = 0, Velocity = new Vector2(0, 1) };
go1.AddComponent(rb1);
go1.AddComponent(new Collider(rb1, go1, 1));
var go2 = physicsScene.Instantiate();
go2.transform.Position = new Vector2(0, 10);
var rb2 = new Rigidbody(go2) { Gravity = 0, Velocity = new Vector2(0, 0) };
go2.AddComponent(rb2);
@MisterKidX
MisterKidX / FinalizerDemo
Created October 26, 2022 14:25
Showing how finalizers work
Managed managed = new Managed();
await Task.Delay(1000);
Console.WriteLine("managed is now null.");
managed = null;
Console.WriteLine("press any key to make the GC collect");
Console.ReadLine();
GC.Collect();
Console.ReadLine();
@MisterKidX
MisterKidX / IEquatableComparison.cs
Last active November 21, 2022 11:39
IEquatable<T> Performance with List<T> and structs
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
int capacity = 10_000_000;
List<Vector3NoEquals> Vector3NoEquals = new(capacity);
List<Vector3WithEquals> Vector3GoodEquals = new(capacity);
List<Vector3WithIEquality> Vector3WithIEquality = new(capacity);
for (int i = 0; i < capacity; i++)
{
@MisterKidX
MisterKidX / DemonstratingIDisposable.cs
Created October 14, 2022 11:34
Demonstrates the use of IDisposable
Console.WriteLine("Creating 50 NotDisposable objects which will" +
" allocate 500mb of memory and will not clean at garbage collection.");
Console.ReadLine();
if(true)
{
NotDisposableContainer container = new NotDisposableContainer();
container.ND = new List<NotDisposable>();
for (int i = 0; i < 50; i++)
container.ND.Add(new NotDisposable());
@MisterKidX
MisterKidX / EqualityComparison.cs
Created October 13, 2022 14:38
Default equality comparison of the C# language
using System;
using System.Collections.Generic;
using System.Diagnostics;
int iterations = 1_000_000;
List<ReflectionComparison> comparisons1 = new List<ReflectionComparison>();
List<ReflectionComparison> comparisons2 = new List<ReflectionComparison>();
List<ByteComparison> comparisons3 = new List<ByteComparison>();
List<ByteComparison> comparisons4 = new List<ByteComparison>();
List<ReferenceType> comparisons5 = new List<ReferenceType>();