Skip to content

Instantly share code, notes, and snippets.

View dpeek's full-sized avatar

David Peek dpeek

View GitHub Profile
@dpeek
dpeek / gist:5794527
Created June 17, 2013 03:43
Abstract color.
class Test
{
static function main()
{
draw(0xFF);
draw(function(x,y){ return 0xFF0000; });
// draw(function(x,y){ return "foo"; }); // compile error, not color
}
static function draw(color:Color)
@dpeek
dpeek / gist:5753876
Created June 11, 2013 01:19
Patches Neko Makefile and installer to work with Homebrew
From 045276ae065567ca2610ef4976c823c54473fa89 Mon Sep 17 00:00:00 2001
From: David Peek <[email protected]>
Date: Tue, 11 Jun 2013 11:13:18 +1000
Subject: [PATCH] Patch required by homebrew formula - no static, paths
---
Makefile | 7 ++++---
src/tools/install.neko | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
class Main
{
public static function main()
{
trace(haxe.Json.stringify({a:1,b:2,c:3}, function(k,v){
return k == "" ? v : v + 10;
}));
}
}
@dpeek
dpeek / gist:4704328
Created February 4, 2013 00:14
Macro getter
class Test
{
public static function main()
{
var test = new Test();
trace(test.style);
}
public function new()
{
@dpeek
dpeek / gist:4700522
Created February 3, 2013 04:09
WebGL enums
package js;
import js.TypedArray;
import js.Canvas;
import js.type.DOMType;
import js.type.GLType;
import js.type.Core;
import js.type.Event;
import js.type.Object;
@dpeek
dpeek / gist:4621204
Created January 24, 2013 12:51
haxe.macro.ExprTools.toString bug
#if macro
using haxe.macro.Tools;
using haxe.macro.Expr;
#end
enum Foo
{
bar;
}
@dpeek
dpeek / gist:4114868
Created November 19, 2012 23:36
haxe.macro.Field.doc doesn't contain docs?
// Test.hx
@:build(Builder.build()) class Test
{
/**
Docs!
*/
public static function main() {}
}
@dpeek
dpeek / gist:3984469
Last active October 12, 2015 06:27
Building Neko and Haxe from Source on OS X 10.8

Requirements

  • OS X Mountain Lion (10.8.1)
  • XCode 4.5.1 with "Command Line Tools" installed in Preferences > Downloads > Components
  • MacPorts Mountain Lion installer.

Install dependencies: (you might want a grab a coffee)

sudo port install boehmgc pcre mysql5 ocaml
@dpeek
dpeek / gist:3704205
Created September 12, 2012 03:57
Formats a large float (eg Date.getTime) as a string with no exponent in cpp.
class FloatHelper
{
/**
Formats a large float (eg Date.getTime) as a string with no exponent in cpp.
1.347420344e+12 -> 1347420344000
*/
function formatFloat(float:Float):String
{
#if cpp
var str = Std.string(float);
@dpeek
dpeek / gist:2802113
Created May 27, 2012 03:58
Haxe setter macro?
// haxe -x SetterTest
#if macro
import haxe.macro.Expr;
#end
class SetterTest
{
public static function main()
{