Skip to content

Instantly share code, notes, and snippets.

View AxGord's full-sized avatar
🦄
Pony

Alexander Gordeyko AxGord

🦄
Pony
View GitHub Profile
class MatrixRotate {
static function main() {
final w = 3;
final h = 2;
final m = [
1, 0, 2,
0, 3, 4
];
p(r90(m, w, h), h, w);
p(r180(m, w, h), w, h);
import pony.events.Event1;
import pony.events.Signal1;
import pony.magic.DI;
import pony.magic.HasListener;
import pony.magic.HasSignal;
import pony.time.DT;
import pony.time.DeltaTime;
@:nullSafety(Strict) class DynamicDeltaTimeService implements HasSignal implements HasListener implements DI {
@AxGord
AxGord / Main.hx
Last active June 4, 2023 22:40
Dependency injection
import haxe.Timer;
import pony.Logable;
import pony.magic.WR;
import pony.magic.DI;
// https://github.com/AxGord/Pony/commit/a0c68a0f5d92798b2054fd39dc9e370c0977f2a4
class Main implements DI {
@:service private final l: Logable = new Logable('Module:');
@:service private final myService: MyService = new MyService();
@AxGord
AxGord / PostGen.hx
Created August 14, 2022 08:52
Post TypeScript to Haxe convert
import sys.io.File;
using StringTools;
final path: String = '../src/';
final ext: String = '.hx';
final map: Map<String, Array<String>> = [
'native package name' => ['Path to file, without extension']
];
package;
import js.Node;
import pony.math.Matrix;
import pony.midi.devices.Launchpad;
import pony.midi.devices.LaunchpadColor;
import pony.text.TextTools;
import pony.time.Timer;
using pony.Tools;
@AxGord
AxGord / UInt.hx
Last active December 11, 2019 19:31
class Main {
private static function main():Void {
trace(-1 > (5: UInt));
}
}
abstract UInt(Int) from Int to Int {
@:op(A + B) private static inline function add(a:UInt, b:UInt):UInt {
import haxe.Constraints.Function;
/*
Result:
src/Main.hx:16: Function bench
src/Main.hx:76: 0.019 sec
src/Main.hx:19: Signal bench
src/Main.hx:76: 0.01 sec
*/
import pony.net.*;
import pony.net.rpc.*;
import pony.events.*;
import pony.time.MainLoop;
class RPCExample {
private static function main():Void {
MainLoop.init();
import pony.net.SocketClient;
import pony.net.SocketServer;
import pony.time.MainLoop;
class NekoSockets {
private static function main():Void {
MainLoop.init();
var port = 12345;
class Test {
static function main() {
var a = new SmartArray([1, 2, 3]);
for (e in a) {
trace(e);
if (e == 2) a.remove(1);
}
}
}