Skip to content

Instantly share code, notes, and snippets.

View markknol's full-sized avatar
🎸
#Haxe

Mark Knol markknol

🎸
#Haxe
View GitHub Profile
@nadako
nadako / Main.hx
Created March 18, 2020 15:59
declaration-site unification check
class Point implements UnifyCheck<{x:Int}> {
public var x:Int;
}
class Main {
static function main() {
}
}
@jdonaldson
jdonaldson / Main.hx
Created December 27, 2019 20:02
Paths example
class Main {
static function main(){
var router = Paths.buildRouter(Page);
var o = router(["Home"]);
trace(o + " is the value for o");
var p = router(["Foo","Baz", "1"]);
trace(p + " is the value for p");
@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();
}
@elsassph
elsassph / 0-Example.hx
Last active May 25, 2016 20:04
Haxe - use macro to generate dispatch code
/*
Automatically generate dispatch functions as:
public function onDoubleArguments(one:String, two:Int) {
for (listener in listeners)
listener.onDoubleArguments(one, two);
}
*/
class Example extends Dispatcher<Dynamic>
{
@elsassph
elsassph / 1-loop-es6.js
Last active December 5, 2016 23:37
ES2015 / babel vs Haxe code generation
const a = [1,2,3];
var acc = 0;
for (const v of a) {
acc += v;
}
// want clean code? use Array.reduce
console.log(acc);
package com.dango_itimi.utils;
import haxe.rtti.Meta;
using com.dango_itimi.utils.MetaUtil;
class MetaField
{
public var name(default, null):String;
public var value(default, null):Array<Dynamic>;
public function new(name:String, value:Array<Dynamic>)
@spyesx
spyesx / adblock-blacklist.css
Last active February 7, 2024 09:48
Class and ID to avoid because of AdBlock
.sidebar_newsletter_sign_up,
.sidebar_subscribe,
.sign-up-form-single,
.signup-form--header,
.signup-with-checkboxes,
.skinny-sign-up,
.slidedown-newsletter,
.small-newsletter,
.social-link-mail,
.social_newsletter_box,
@natevogt
natevogt / gist:8f9e49ec1f4883dc71db
Created September 9, 2015 19:18
Apple keynote 9/9/2015
incredible
incredible
incredible
beautiful
really beautiful
fantastic
amazing
incredible
great
incredible
@kevinresol
kevinresol / AssetPaths.hx
Created August 22, 2015 01:44
Macro to read asset paths
package util;
/**
* ...
* @author Kevin
*/
@:build(util.AssetPathsMacro.build())
class AssetPaths
{
@hamaluik
hamaluik / !Profiler.hx
Last active April 6, 2020 23:11
Simple Haxe Profiler
package ;
import haxe.ds.StringMap;
import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.Printer;
import haxe.macro.Type.ClassType;
import neko.Lib;
using haxe.macro.ExprTools;