Skip to content

Instantly share code, notes, and snippets.

abstract FunctionReturning<T>(Dynamic) {
inline function new (x:Dynamic) this = x;
@:from static inline function from0 <T>(x:Void->T):FunctionReturning<T> return new FunctionReturning(x);
@:from static inline function from1 <T>(x:Dynamic->T):FunctionReturning<T> return new FunctionReturning(x);
@:from static inline function from2 <T>(x:Dynamic->Dynamic->T):FunctionReturning<T> return new FunctionReturning(x);
@:from static inline function from3 <T>(x:Dynamic->Dynamic->Dynamic->T):FunctionReturning<T> return new FunctionReturning(x);
/* ... */
}
class Test {
var vm = require('vm'),
code = 'var square = n * n;',
fn = new Function('n', code),
script = vm.createScript(code),
sandbox;
n = 5;
sandbox = { n: n };
benchmark = function(title, funk) {
package tests;
import js.Node;
using AsyncLambda;
class TestNode implements async.Build{
@:async static function writeAll(fd:Int, content:String){
var total = 0, length = content.length;
while (total > length){
async(written = Node.fs.write(fd, content, total, length - total, null));
total+= written;
/**
* Renders a lighting mask which can be added to the display list via Bitmap.
* @author Sam MacPherson
*/
package as3gl.lighting;
import as3gl.core.Destroyable;
import as3gl.core.Runnable;
import as3gl.display.Batcher;
using System;
using UnityEngine;
using System.Collections;
public class AssetBundleSample : MonoBehaviour {
public GUIText guitext;
// Use this for initialization
void Start () {
class Module1
{
static function main() {
SharedCode.greet("Jason");
}
}
@sonygod
sonygod / Module.hx
Created November 19, 2013 13:31 — forked from back2dos/Module.hx
package ;
import haxe.macro.Type;
import haxe.macro.Expr;
import haxe.macro.Context;
class Module {
static function build(?module:String) {
function isIncluded(meta:MetaAccess)
package amd;
#if macro
import haxe.macro.Type;
import haxe.macro.Expr;
import haxe.macro.*;
import haxe.ds.*;
using Lambda;
@sonygod
sonygod / gist:260ea88f966f5334d125
Last active August 29, 2015 14:26 — forked from allanolivei/gist:9260107
Unity 3d : Get Selected Folder in Project Window
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
public static class UnityUtil
{
public static string GetSelectedPathOrFallback()
{
string path = "Assets";
@sonygod
sonygod / Our.cs
Created February 22, 2016 03:31 — forked from robert-nix/Our.cs
Hack tool to rewrite Hearthstone's Unity3d asset files with a custom assembly/monobehaviour
using System;
using System.IO;
using System.Threading;
using UnityEngine;
public class OurMono : MonoBehaviour
{
StreamWriter log;
Timer t;