Skip to content

Instantly share code, notes, and snippets.

View mqp's full-sized avatar

Marshall Polaris mqp

  • Mountain View, CA
View GitHub Profile
@mqp
mqp / resource-example.cs
Created February 28, 2017 21:44
Illustrates different ways of loading resources in Unity.
public class ResourceExample : MonoBehavior
{
private GameObject RuntimeLoadedPrefabA;
private GameObject RuntimeLoadedPrefabB;
private GameObject RuntimeLoadedPrefabC;
private GameObject RuntimeLoadedPrefabD;
private GameObject RuntimeLoadedPrefabE;
private GameObject RuntimeLoadedPrefabF;
@mqp
mqp / metric.cs
Created November 5, 2016 00:10
Incremental mystery metric computation
internal void UpdateRoundTripTimeAndVariance(int lastRoundtripTime)
{
if (lastRoundtripTime < 0)
{
return;
}
this.roundTripTimeVariance -= this.roundTripTimeVariance / 4;
if (lastRoundtripTime >= this.roundTripTime)
{
this.roundTripTime += (lastRoundtripTime - this.roundTripTime) / 8;
@mqp
mqp / ComponentCachedGameObject.cs
Last active September 23, 2016 00:57
ComponentCachedGameObject example
using System;
using System.Collections.Generic;
using UnityEngine;
public static class ComponentCachingDemo
{
public static Dictionary<int, ComponentCachedGameObject> gameObjectsByMeshId;
public static void AddObjects()
{
@mqp
mqp / keybase.md
Created December 3, 2015 00:24
Keybase proof of identity

Keybase proof

I hereby claim:

  • I am maugrim on github.
  • I am mquander (https://keybase.io/mquander) on keybase.
  • I have a public key ASAHmK98lT2L5S0Vec_AXgnkWKox7rdoI-7vEMfmbnSw0wo

To claim this, I am signing this object:

@mqp
mqp / test.c
Created April 1, 2011 23:24
TCO subtleties with C compilers
#include <stdio.h>
long acc_normal_rec(long n, long acc)
{
if (n == 0) return acc;
long localacc = acc + 1;
return acc_normal_rec(n-1, localacc);
}
long acc_normal(long n)