Skip to content

Instantly share code, notes, and snippets.

@dkolyesnik
dkolyesnik / gist:faaedb9bb40990e69ed32708f01c8390
Created November 30, 2016 21:07
Strictly typed events example in Haxe
import haxe.Constraints.Function;
class Test {
static function main() {
trace("Haxe is great!");
var dispatcher = new EventDispatcher();
dispatcher.addEventListener(MouseEvent.CLICK, onClick);
dispatcher.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
static function onClick(event:MouseEvent):Void
import haxe.Constraints.Function;
class Test {
static function main() {
trace("Haxe is great!");
var dispatcher = new EventDispatcher();
dispatcher.addEventListener(new Handler<MouseEvent>(MouseEvent.CLICK, onClick));
dispatcher.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
static function onClick(event:MouseEvent):Void
@dkolyesnik
dkolyesnik / gist:aa4a8871816fcc1df2a2cc960667c180
Created December 20, 2016 21:21
Creating a field with parameterized type
class MyMacro{
macro public static function build(name:String):Array<Field> {
var fields = Context.getBuildFields();
for (f in fields){
if (f.name == name){
var type = switch(f.kind){
case FVar(t):t;
default: throw new Error("Invalid field type", f.pos);
}
var array:Field = {
:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
@echo off
CLS
ECHO.
ECHO =============================
ECHO Running Admin shell
ECHO =============================
// Generated by Haxe 3.4.0 (git build development @ e2ed327)
#pragma warning disable 109, 114, 219, 429, 168, 162
namespace haxe.lang {
public class Function {
public Function(int arity, int type) {
this.__fn_type = type;
this.__hx_arity = arity;
}
package abstracts;
#if cs
import cs.system.Action_1;
abstract Callback(cs.system.Action_1<String>) from Action_1<String> to Action_1<String>
{
function new(f)
{
this = f;
}
public function invokeIt(data:String):Void
#if macro
class InitMacro
{
public static function removeInterface(interfaceName:String):Void
{
Context.onAfterTyping(function (types:Array<haxe.macro.Type.ModuleType>){
trace('removing $interfaceName');
for (moduleType in types)
{
switch(moduleType)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Sorcery.Collections
{
interface IReadOnlyList<T>
{
int Count { get; }
@dkolyesnik
dkolyesnik / Dark-color-theme.json
Last active November 4, 2017 21:58
vs code dark theme
{
"name":"DarkMy",
"type": "dark",
"colors": {
"editor.background": "#282828",
"editor.foreground": "#beb8b8",
"editor.selectionBackground": "#30434c",
"editor.lineHighlightBackground": "#2b3c44",
"editorCursor.foreground": "#fdf4c1",
"editorWhitespace.foreground": "#504945",
@dkolyesnik
dkolyesnik / FTW.hx
Created April 1, 2018 11:23 — forked from dpeek/FTW.hx
import haxe.macro.Expr;
class FTW
{
public static function build()
{
return haxe.macro.Context.getBuildFields().map(transformField);
}
static function transformField(field:Field)