Skip to content

Instantly share code, notes, and snippets.

View NullEntity's full-sized avatar

Bryce Walther NullEntity

  • Philadelphia, PA
View GitHub Profile
@NullEntity
NullEntity / CustomDictionaryConverter.cs
Created July 16, 2017 01:49
Saves a dictionary as key/value pairs. Importantly, it uses JsonConverters on the dictionary keys which the default JsonSerializer doesn't do.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
public class CustomDictionaryConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
private static void RemoveMissingComponentsInCurrentScene(ILevelData levelData)
{
var badComponents = SceneManager
.GetActiveScene()
.GetRootGameObjects()
.Flatten()
.Select(gameObject => new
{
GameObject = gameObject,
Components = gameObject.GetComponents<Component>()
public class PostActionTransformation<T> : ISpecimenBuilderTransformation
{
private readonly List<ISpecimenCommand> _commands = new List<ISpecimenCommand>();
public ISpecimenBuilder Transform(ISpecimenBuilder builder)
{
return new Postprocessor(
builder,
new CompositeSpecimenCommand(_commands),
new IsAssignableToTypeSpecification(typeof(T)));
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
namespace Domm.Engine
{
public class Recipe
{
private readonly IReadOnlyDictionary<IIngredient, int> _ingredients;
private void BindStateMachineBehavioursInActiveScenes()
{
Enumerable.Range(0, SceneManager.sceneCount)
.Select(SceneManager.GetSceneAt)
.SelectMany(ZenUtilInternal.GetRootGameObjects)
.SelectMany(x => x.GetComponentsInChildren<Animator>(true))
.SelectMany(x => x.GetBehaviours<StateMachineBehaviour>())
.ForEach(Container.QueueForInject);
}
@NullEntity
NullEntity / GetHashCodeBenchmark.cs
Last active February 5, 2019 20:33
Hash Code Distribution Test
using System.Collections;
namespace HashCodeDistributionTest
{
public class GetHashCodeBenchmark
{
private static readonly Hashtable _evenDistributes = new Hashtable();
private static readonly Hashtable _counters = new Hashtable();
public class EvenDistributed