Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am fponticelli on github.
* I am fponticelli (https://keybase.io/fponticelli) on keybase.
* I have a public key whose fingerprint is D665 0895 F02A 5D6F 3089 7965 9CEC 6A8B B344 787C
To claim this, I am signing this object:
@fponticelli
fponticelli / Server.hx
Last active April 29, 2016 15:51
A multi-process webserver with abe and nodejs + cluster.
import abe.App;
import bl.server.*;
import js.Node.*;
import js.node.Cluster;
import js.node.Os;
import npm.Chalk.*;
class Server {
public static var defaultPort(default, null) = 8787;
public static var defaultHost(default, null) = "0.0.0.0";
@fponticelli
fponticelli / Request.hx
Created April 4, 2016 02:43
typed request
package bl.common;
using thx.promise.Promise;
import thx.Url;
import js.html.XMLHttpRequest;
import js.html.XMLHttpRequestResponseType;
class Request<T> {
public var response(default, null) : Promise<T>;
var request : XMLHttpRequest;
@fponticelli
fponticelli / Button.hx
Last active March 13, 2016 00:20
brainstorm on typed component styling
import doom.Html.*;
class Button extends doom.html.Component<ButtonPropps> {
override function render() {
return button([
"class" => props.status,
"click" => props.trigger
], children);
}
}
private typedef _SActionFunc = EntityScript -> _SA -> Void;
private class _SActions {
// Every function in this class must be of type _SActionFunc.
// Who knows what will happen if this is not true.
public static function Idle(entity:EntityScript, action:_SA):Void {
}
public static function AnotherAction(entity:EntityScript, action:_SA):Void {
}
@fponticelli
fponticelli / Lazy.hx
Created September 16, 2015 17:19
Lazy evaluation of remote files
import js.node.vm.Script;
using thx.promise.Promise;
class Lazy {
static var map : Map<String, Script> = new Map();
public static function load(path : String) : Promise<{} -> String> {
var script = map.get(path);
if(null != script) {
return Promise.value(loadScript(script));
}
@fponticelli
fponticelli / Main.hx
Created March 11, 2015 14:46
small js.Promise test
import js.Promise;
class Main {
static function main() {
var p1 = new Promise(function(resolve, reject) {
resolve("YES");
});
p1.then(function(v) trace(v), function(e) trace('NOOO!! $e'));
var p2 = new Promise(function(resolve, reject) {
@fponticelli
fponticelli / Router.hx
Last active August 29, 2015 14:16
extern issue
import express.Request;
import express.Response;
import express.Next;
import express.Middleware;
import express.Express;
import abe.Router;
class Main {
public static function main() {
var router = new abe.Router(null);
@fponticelli
fponticelli / Auth.hx
Created February 24, 2015 17:53
sample Auth with abe
@:use(mw.BodyParser.json())
class Auth implements abe.IRoute {
@:post("/auth")
@:args(body)
function login(user : String, password : String) {
response.send('$user:$password');
}
}
@fponticelli
fponticelli / Main.hx
Created February 15, 2015 16:21
Minimalistic Webserver with NodeJS + Express + Haxe (with Macros) and an experimental library called restx
import restx.App;
class Main implements restx.IRoute {
@:path("/")
function index()
response.send("Hello World!");
public static function main() {
var app = new App(9998);
app.router.register(new Main());