Skip to content

Instantly share code, notes, and snippets.

local delegates = {}
local function OnEvent(evt, cb)
local cb_dump = string.dump(cb)
delegates[evt] = cb_dump
end
-- declare callbacks
OnEvent('hit', function(evt)
damage(evt.source)
@jagt
jagt / RoslynCodeGen.cs
Created December 15, 2017 15:16
Sample roslyn code generation
using System;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Editing;
// ref https://msdn.microsoft.com/en-us/magazine/mt707527.aspx
// needed packages
// Microsoft.CSharp;
// Microsoft.CodeAnalysis;
// Microsoft.CodeAnalysis.CSharp;
// Microsoft.CodeAnalysis.CSharp.Workspaces;

Keybase proof

I hereby claim:

  • I am jagt on github.
  • I am jagttt (https://keybase.io/jagttt) on keybase.
  • I have a public key ASDs3668qJlLyYQI6xEOskXsa6Pp_a8I2gqq2TkOu7cOnQo

To claim this, I am signing this object:

@jagt
jagt / AltDumpSnapshot.cs
Last active January 11, 2021 11:39
Dump Unity 5.3x memory profiler snapshot directly to file so it wont freeze the window and can be diffed on.
using UnityEditor;
using UnityEditor.MemoryProfiler;
using System;
using System.IO;
using System.Collections.Generic;
// Standalone menu item to dump memory to a text format that's
// more easier to diff on.
namespace MemoryProfilerWindow
@jagt
jagt / MessagePackBinarySample.cs
Created June 14, 2017 12:47
Example usage of MessagePackBinary from MessagePack-CSharp
using System;
using System.Collections.Generic;
using UnityEngine;
using MessagePack;
using NUnit.Framework;
public class MessagePackBasics
{
[Test]
public void Basic()
@jagt
jagt / Program.cs
Last active July 10, 2016 17:36
RunLengthEncoding.cs
using System;
using System.Text;
using System.Diagnostics;
namespace RLE
{
class Program
{
public static string ByteArrayToString(byte[] ba, int len, int offset)
{
@jagt
jagt / MonoLLAPI.cs
Created June 21, 2016 06:53
uNet LLAPI working kitchen sink
using UnityEngine;
using UnityEngine.Networking;
using System.Text;
using System.Collections.Generic;
public class MonoLLAPI : MonoBehaviour {
int reliableStateUpdateChannel;
int unreliableChannel;
@jagt
jagt / Makefile
Created January 26, 2016 14:54
LLVM Hello World from book w/ llvm-3.6
LLVM_CONFIG?=llvm-config-3.6
ifndef VERBOSE
QUIET:=@
endif
SRC_DIR?=$(PWD)
LDFLAGS+=$(shell $(LLVM_CONFIG) --ldflags)
COMMON_FLAGS=-Wall -Wextra
CXXFLAGS+=$(COMMON_FLAGS) $(shell $(LLVM_CONFIG) --cxxflags) -fno-rtti
@jagt
jagt / Freezable.cs
Created December 6, 2015 03:12
Castle Dynamic Proxy Example
using System;
using System.Collections.Generic;
using Castle.DynamicProxy.Generators;
using Castle.DynamicProxy;
// http://kozmic.net/2008/12/16/castle-dynamicproxy-tutorial-part-i-introduction/
public interface IFreezable
{
bool IsFrozen { get; }
@jagt
jagt / fsMagicFloat.cs
Created July 28, 2015 08:42
Full serializer custom converter.
using System;
using System.Collections.Generic;
using FullInspector;
using FullSerializer;
using UnityEngine;
public class Foo
{