Skip to content

Instantly share code, notes, and snippets.

Sean kornman00

View GitHub Profile
kornman00 / sort.xslt
Created Mar 14, 2017
Sort non 1st level XML elements and their attributes for better diffing
View sort.xslt
<xsl:stylesheet version="1.0"
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:apply-templates select="@*">
<xsl:sort select="name()"/>
kornman00 / objects.xml
Created Feb 19, 2017
Change building commands in Halo Wars supporting docs
View objects.xml
<Object name="unsc_bldg_barracks_01" id="0" dbid="137">
<Command Type="TrainSquad" Position="1">unsc_inf_marine_01</Command>
<Command Type="TrainSquad" Position="1">unsc_inf_odst_01</Command>
<Command Type="TrainSquad" Position="2">unsc_inf_flameMarine_01</Command>
<Command Type="TrainSquad" Position="3">unsc_inf_spartan_01</Command>
<Command Type="Research" Position="7">unsc_marine_upgrade1</Command>
<Command Type="Research" Position="7">unsc_marine_upgrade2</Command>
<Command Type="Research" Position="7">unsc_marine_upgrade3</Command>
<Command Type="Research" Position="7">unsc_odst_upgrade1</Command>
kornman00 / After.cs
Created Apr 14, 2016
Avoiding heap allocations in generic serialization code
View After.cs
// #NOTE: be mindful of how large T actually is and whether or not your runtime does or doesn't
// optimize passing large structs by reference instead of copying bits to other parts of the stack
public static T Read<T>(this BinaryReader reader, T item = default(T))
where T : IStreamSerializable, new()
if (item == null) // value types are never null, so this helps us avoid heap allocations
item = new T();
return item;
kornman00 / EnumAndCustomComparer.cs
Created Apr 12, 2016
The power of per-frame GC analysis blog source
View EnumAndCustomComparer.cs
// #IMPL: If you change the underlying type, update ProtoSomething.ComparerImpl too!
public enum HardCodedThing : byte
kornman00 / ProfilerWindowInterop.cs
Created Feb 21, 2016
Preferences editor for Unity3D's profiler window
View ProfilerWindowInterop.cs
// Use at your own risk.
// Should work with any Unity Editor since at least 4.6
// These macros make it so changes aren't actually committed to the EditorPrefs. Instead, changes are Debug.Log'd
// You'll need this defined, unless you have my BitVector32 from
using System;
kornman00 / SeeingSharpCpp_Statics.cs
Created Dec 13, 2015
Code Listings for Seeing Sharp C++: Behind the IL2CPP magic of Metadata and Statics
View SeeingSharpCpp_Statics.cs
using System;
namespace SharpCpp
public struct ValueTypeWithCctor
public int Value;
// Comment this out and the CPP code for operator+ won't have a prologue nor invoke IL2CPP_RUNTIME_CLASS_INIT.
// This causes a hidden cctor to be generated by the compiler.
kornman00 / SeeingSharpCpp_Il2CppSetOption.cpp
Created Nov 30, 2015
Code Listings for Seeing Sharp C++: The Il2CppSetOption attribute
View SeeingSharpCpp_Il2CppSetOption.cpp
extern TypeInfo* Int32U5BU5D_t1872284309_0_il2cpp_TypeInfo_var;
// NOTE: 'Int32U5BU5D_t1872284309_0' is to IL2CPP as 'int[]' is to C#
// System.Int32 SharpCpp.SharpCode::Il2CppSetOption_ChecksEnabled()
extern "C" int32_t SharpCode_Il2CppSetOption_ChecksEnabled_m_1098767581_0 (Object_t * __this /* static, unused */, const MethodInfo* method)
Int32U5BU5D_t1872284309_0* V_0 = {0};
//var array = new int[1];
kornman00 / GetDelegateForFunctionPointer.cs
Created Aug 18, 2012
GetDelegateForFunctionPointer, kornman00
View GetDelegateForFunctionPointer.cs
using System;
using System.Linq;
using Contracts = System.Diagnostics.Contracts;
using Contract = System.Diagnostics.Contracts.Contract;
using Reflect = System.Reflection;
using Interop = System.Runtime.InteropServices;
namespace KSoft.Reflection
public static partial class Util
You can’t perform that action at this time.