Skip to content

Instantly share code, notes, and snippets.

View dpeek's full-sized avatar

David Peek dpeek

View GitHub Profile
@dpeek
dpeek / gist:1270290
Created October 7, 2011 13:35
Typed Signals with Generics
class Main
{
public static function main()
{
new Main();
}
public function new()
{
var signal0 = new Signal0();
@dpeek
dpeek / gist:1368618
Created November 15, 2011 22:45
Read JPG size in Neko
var b = bytes.get;
var s = bytes.readString;
var i = 0;
var l = bytes.length;
if (b(i) == 0xFF && b(i+1) == 0xD8 && b(i+2) == 0xFF && b(i+3) == 0xE0)
{
i += 4;
if (s(i+2,1) == "J" && s(i+3,1) == "F" && s(i+4,1) == "I" && s(i+5,1) == "F" && b(i+6) == 0x00)
@dpeek
dpeek / gist:2310849
Created April 5, 2012 12:52
History/tab completion for Neko programs
class Main
{
public static function main()
{
print(">> ");
var position = -1;
var history = [];
var input = "";
@dpeek
dpeek / gist:2779204
Created May 24, 2012 03:03
Entities
// declaration
class TestEntity extends Entity
{
@:attr var attribute:Int = 0;
}
// haxe
test1.attribute = 10;
@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()
{
@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: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: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: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: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;