Skip to content

Instantly share code, notes, and snippets.

@bamboo
bamboo / evalstresstest.c
Created September 9, 2011 20:13
Eval with appdomain reload
#include "stdafx.h"
#include <glib.h>
#include <mono/mini/jit.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/threads.h>
extern "C" {
#include <mono/metadata/mono-debug.h>
}
#include <mono/metadata/mono-gc.h>
@bamboo
bamboo / strip-non-tip-heads.boo
Created August 8, 2011 18:18
stripping all revisions from a non tip head in mercurial
def hg(command):
return shell("hg", command)
def strip(rev):
return hg("strip $rev")
def heads():
return hg("heads")
def nextNonTipRevision():
@bamboo
bamboo / gist:1109212
Created July 27, 2011 12:06
Zip and Tuple.Create
foreach (var argAndParameterType in invocationExpression.Arguments.Zip(method.ParameterTypes(), Tuple.Create))
PreserveSemanticsForInvocationArgument(argAndParameterType.Item1, argAndParameterType.Item2);
@bamboo
bamboo / gist:1063808
Created July 4, 2011 19:16
Emacs: opening all actionscript files in a directory
(require 'find-lisp)
(defun open-actionscript-files-in (dir-path)
(interactive "s")
(mapc 'find-file (find-lisp-find-files dir-path "\\.as$")))
@bamboo
bamboo / fogbugz.clj
Created June 14, 2011 18:17
interacting with fogbugz using clojure
(ns fogbugz
(:use [clojure.xml :as xml]))
(def *base-url* "https://intra.unity3d.com/fogbugz/api.asp?")
(defn query-string-from-map [m]
(apply str (interpose "&" (for [[key value] m] (str (name key) "=" value)))))
(defn rest-call [args]
(let [query-string (query-string-from-map args)]
@bamboo
bamboo / MacroResolvingTypeArgument.boo
Created May 27, 2011 14:03
Macro resolving a type argument
import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.MetaProgramming // compile_
import Boo.Lang.Compiler.TypeSystem
import Boo.Lang.Compiler.TypeSystem.Services
import Boo.Lang.Environments
struct Vector3:
x as single
y as single
@bamboo
bamboo / gist:980973
Created May 19, 2011 15:08
alchemy - struct instantiation
static AS3_Val Vector3f_DefaultValue() {
static AS3_Val (*DefaultValueShim)() = NULL;
if (DefaultValueShim == NULL) {
AS3_Val UnityEngine = AS3_String("UnityEngine");
AS3_Val Vector3_class = AS3_NSGetS(UnityEngine, "Vector3");
AS3_Val DefaultValue = AS3_GetS(Vector3_class, "DefaultValue");
DefaultValueShim = AS3_Shim(DefaultValue, null, "AS3ValType", false);
AS3_Release(DefaultValue);
AS3_Release(Vector3_class);
AS3_Release(UnityEngine);
package UnityEngine.Serialization {
class ActionScriptDeserializer {
public static function Deserialize(instance: IDeserializable, buffer: ByteArray, offset: int): int {
var reader = new SerializedStateReader(buffer, offset);
instance.Deserialize(reader);
return reader.offset;
}
}
@bamboo
bamboo / assign.boo
Created February 9, 2011 19:47
Meta method expanding named arguments into property assignments.
import System
import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.Services
import Boo.Lang.Environments
import Boo.Lang.Compiler.MetaProgramming
[meta]
def assign(e as MethodInvocationExpression):
"""
@bamboo
bamboo / DeepProfilingAttribute.boo
Created January 19, 2011 20:12
Wraps every method with Profiler.BeginSample/Profiler.EndSample calls.
import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
class DeepProfilingAttribute(AbstractAstAttribute):
"""
Wraps every method with Profiler.BeginSample/Profiler.EndSample calls.
Save it to the Plugins folder of your Unity project and enable it on a per script basis using:
@script DeepProfiling()