Skip to content

Instantly share code, notes, and snippets.

View AxGord's full-sized avatar
🦄
Pony

Alexander Gordeyko AxGord

🦄
Pony
View GitHub Profile
@AxGord
AxGord / Main.hx
Created October 27, 2014 12:32
Appveyor munit helper
package;
import sys.io.File;
/**
* Appveyor munit helper
* @author AxGord
*/
class Main {
@AxGord
AxGord / SlowServer.hx
Last active August 29, 2015 14:14
Haxe/Node.JS simple slow server for testing loaders.
package;
import haxe.Timer;
import js.Node;
/**
* SlowServer
* @author AxGord
*/
class SlowServer {
package;
import pony.net.SocketClient;
import pony.net.SocketServer;
class StringSocketExample
{
static function main()
{
import pony.net.http.HttpServer;
import pony.net.http.IHttpConnection;
class HttpServerExample {
static function main() {
new HttpServer().request = function(connection:IHttpConnection) {
connection.sendText('Hello world');
};
}
Neko
Main.hx:27: 224.676000595093
Main.hx:40: 356.434999465942
Cpp (32bit)
Main.hx:27: 20.1340007781982
Main.hx:40: 106.84700012207
C# (64bit)
Main.hx:27: 15.3541984558105
Main.hx:40: 234.727904319763
Java
package;
import pony.Priority;
import haxe.Constraints.Function;
#if (cs||java)
typedef Listener1<T1> = {args:Int, f:T1->Void};
#else
typedef Listener1<T1> = T1->Void;
#end
@AxGord
AxGord / SignalTest.hx
Last active September 17, 2015 16:22
package;
import pony.events.Signal;
/**
* ...
* @author AxGord <axgord@gmail.com>
*/
class SignalTest {
static function main() {
macro public function add(th:Expr, f:Expr, ?priority:ExprOf<Int>):Expr {
if (priority == null) priority = macro 0;
return switch Context.typeExpr(f).t {
case TFun(args, ret):
switch ret {
case TAbstract(t, p):
var n = t.get().name;
if (n != 'Bool' && n != 'Void')
Context.fatalError('Wrong return type', Context.currentPos());
@AxGord
AxGord / Streams.hx
Last active September 26, 2015 01:16
Using pony signals for streams
static function streamToString() {
var streamInput = new Event1<Int>();
var streamOutput:Signal1<Int> = streamInput;
var subStream = streamOutput.convert1(
function(e:Event1<String>, v:Int) e.dispatch(v == 2 ? 'two' : Std.string(v))
);
subStream.add(function(s:String) trace(s));
@AxGord
AxGord / gist:5730835
Last active December 18, 2015 05:09
HScript live coding. Using in https://github.com/AxGord/LiveTeacher
package ;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.Lib;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.events.Event;
/**