Skip to content

Instantly share code, notes, and snippets.

@sonygod
sonygod / Test.hx
Created April 11, 2013 12:28
compare async and sync performance
package ;
/**
* ...
* @author sonygod
*/
import async.Build;
import async.Async;
import haxe.Timer;
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;
@sonygod
sonygod / vm.js
Created April 15, 2013 10:22
nodejs vm
var vm = require('vm'),
code = 'var square = n * n; console.log(n+"");',
fn = new Function('n', code),
script = vm.createScript(code),
sandbox;
n = 5;
sandbox = { n: n };
@sonygod
sonygod / Nodevm.hx
Created April 16, 2013 02:47
test nodevm in async excute
package ;
import js.Node;
import async.Build;
import org.transition9.async.Step;
/**
* ...
* test nodevm in async excute
* @author sonygod
@sonygod
sonygod / Main.hx
Created April 16, 2013 08:14
base communication between js and flash test
/**
* base communication between js and flash test
*
*/
package ;
import haxe.remoting.ExternalConnection;
import haxe.remoting.Context;
import haxe.Timer;
@sonygod
sonygod / JsMain.hx
Created April 17, 2013 08:30
haxe remoting call from js to flash
package ;
//import haxe.Timer;
import js.Browser;
import haxe.remoting.ExternalConnection;
import tink.lang.Cls;
class JsMain {
public static function foo(obj) {
return obj.x + obj.y; }
@sonygod
sonygod / FlashMain.hx
Created April 18, 2013 09:55
base haxe flash and js remoting use async
package ;
import haxe.ds.ObjectMap;
import haxe.Timer;
import haxe.remoting.ExternalConnection;
import tink.lang.Cls;
/**
* ...
* @author sonygod
*/
@sonygod
sonygod / FlashMain.hx
Last active December 16, 2015 09:19
haxe flash js remoting use async flash---async ---js js----async--flash this version only work on firefox, I don't know why ,maybe haxe Timer ge tsomthing wrong. try to build this ,you need tinkerbell r6388 , hx-async full code and project here https://github.com/sonygod/fj_aync
package ;
import haxe.ds.ObjectMap;
import haxe.ds.StringMap;
import haxe.Timer;
import haxe.remoting.ExternalConnection;
import tink.lang.Cls;
import Format;
/**
* ...
* @author sonygod
@sonygod
sonygod / Test.hx
Created April 23, 2013 08:22
test hxasync
package ;
/**
* ...
* @author sonygod
*/
import async.Build;
import async.Async;
import haxe.Timer;
/**
* 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;