Skip to content

Instantly share code, notes, and snippets.

@RealyUniqueName
RealyUniqueName / Json.hx
Last active February 10, 2022 15:45
Sample PHP externs for Haxe
//You can use any package name here.
//It's not required to match the namespace of php file.
package;
import php.NativeStructArray;
typedef EncodingOptions = {
?prettyPrint:Bool,
?enableJsonExprFinder:Bool,
}
@RealyUniqueName
RealyUniqueName / KeyValueIterator.hx
Last active October 14, 2016 10:35
Key-value map iterator
class KeyValueIterator<K,V> {
var map:Map<K,V>;
var keys:Iterator<K>;
static public inline function pairs<K,V>(map:Map<K,V>) return new KeyValueIterator(map);
public inline function new(map:Map<K,V>) {
this.map = map;
this.keys = map.keys();
}
@RealyUniqueName
RealyUniqueName / Test.hx
Created August 13, 2016 03:17
New php generator for Haxe
package example;
import php7.Exception;
class TestSuper {
function new () {}
function superMethod () return [Std.random(2), Std.random(2)][Std.random(2)];
@RealyUniqueName
RealyUniqueName / Main.hx
Created February 15, 2016 18:23
Minimal slider example for StablexUI
package;
import flash.Lib;
import ru.stablex.ui.skins.Paint;
import ru.stablex.ui.UIBuilder;
import ru.stablex.ui.widgets.Slider;
/**
* Simple demo project for StablexUI
@RealyUniqueName
RealyUniqueName / EventBuilder.hx
Last active October 30, 2015 09:49
Add getter & setter to openfl.events.Event
package;
import haxe.macro.Context;
import haxe.macro.Expr;
class EventBuilder
{
/**
* Description
@:native('\\phpmailerNamespace\\PHPMailer')
extern class PHPMailerNative
{
public function addAttachment( path : String, name : String = "", encoding : String = "base64", type : String = "", disposition : String = "attachment" ) : Bool
}
class PHPMailer extends PHPMailerNative
{
override public function addAttachment( path : String, name : String = "", encoding : String = "base64", type : String = "", disposition : String = "attachment" ) : Bool
@RealyUniqueName
RealyUniqueName / Main.hx
Created August 29, 2015 07:44
Get string representation of function signature
import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.Type;
using haxe.macro.Tools;
class Main
{
package;
import datetime.DateTime;
import datetime.Timezone;
class Test {
static public function main () {
var utc = DateTime.now();
var zone = Timezone.local();
@RealyUniqueName
RealyUniqueName / Exception.hx
Created November 28, 2013 12:09
Simple exception class with stack information
package fst.exception;
import haxe.CallStack;
/**
* Exceptions base
*
*/
class Exception {
@RealyUniqueName
RealyUniqueName / Base.hx
Last active December 27, 2015 03:59
haxe.macro.MacroType issue
package ;
/**
* Base class
*
*/
class Base{
}//class Base