Skip to content

Instantly share code, notes, and snippets.

View jdonaldson's full-sized avatar

Justin Donaldson jdonaldson

  • Mercer Island, Washington
  • 22:46 (UTC -07:00)
View GitHub Profile
import haxe.macro.Expr;
import haxe.macro.Context;
using Lambda;
@:autoBuild(AbstractClassBuilder.build())
interface AbstractClass {}
class AbstractClassBuilder {
static var abstractFields:Hash<Array<String>> = new Hash();
@jdonaldson
jdonaldson / Test.hx
Last active December 13, 2015 20:58
class Test {
static function main() {
var f:Escaped = '<div>foo</div>';
var k:Foo = {k:'<div>blah!</div>'};
trace(f); // not escaped, simple trace
trace(k); // not escaped, simple trace
trace(f + ' some other string'); // escaped!
trace(k.k + ' extra'); // escaped as field access!
@jdonaldson
jdonaldson / index.html
Created December 14, 2012 20:44
Force directed network of WebKit class dependencies (no Event/EventListener)
<!DOCTYPE html>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
<script src="https://raw.github.com/bigmlcom/tipsy/master/src/javascripts/jquery.tipsy.js" type="text/javascript" charset="utf-8"></script>
<style>
.tipsy { font-size: 10px; position: absolute; padding: 5px; z-index: 100000; }
.tipsy-inner { background-color: #000; color: #FFF; max-width: 200px; padding: 5px 8px 4px 8px; text-align: center; }
/* Rounded corners */
.tipsy-inner { border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; }
@jdonaldson
jdonaldson / Escape.hx
Created October 31, 2012 19:49
Extended Html escape/unescape methods
class Escape{
/**
Escape HTML special characters of the string.
&, <, >, ", ', `, , !, @, $, %, (, ), =, +, {, }, [, and ]
**/
public static function htmlEscape( s : String ) : String {
return s.split("&").join("&amp;")
.split("<").join("&lt;")
.split(">").join("&gt;")
.split('"').join("&quot;")
@jdonaldson
jdonaldson / nginx.rb
Created September 27, 2012 23:32 — forked from mranallo/nginx.rb
Homebrew recipe for nginx with upload modules.
require 'formula'
class Nginx < Formula
homepage 'http://nginx.org/'
url 'http://nginx.org/download/nginx-1.2.3.tar.gz'
sha1 '98059ae08ebbfaaead868128f7b66ebce16be9af'
devel do
url 'http://nginx.org/download/nginx-1.3.5.tar.gz'
sha1 'ce0245295f23a54f10d916eb6b7b34469d0618a1'
{
"name": "flare",
"children": [
{
"name": "vis",
"children": [
{
"name": "events",
"children": [
{"name": "DataEvent", "size": 2200,
@jdonaldson
jdonaldson / MacroLambda.hx
Created February 24, 2012 00:06
MacroLambda: Automatically return new lists or arrays depending on the map argument type.
import haxe.macro.Expr;
import haxe.macro.Context;
class MacroLambda
{
public static function main(): Void
{
trace('Hello World');
@jdonaldson
jdonaldson / Jsonify.hx
Last active September 28, 2015 18:38
Create compile-time typed objects from arbitrary json strings
#if macro
import haxe.macro.Expr;
import haxe.macro.Context;
import hxjson2.JSON;
import haxe.Http;
import neko.FileSystem;
#end
class Jsonify {
@jdonaldson
jdonaldson / JsonHxDef.hx
Created December 10, 2011 01:54
jsonhxdef is a ruby script that helps you quickly define a typedef from some arbitary json
typedef JsonObj = {
glossary:Glossary,
}
typedef Glossary = {
title:String,
GlossDiv:GlossDiv,
}
typedef GlossDiv = {
// Copyright (c) 2011, the HaXe project authors.
// All rights reserved.
// Simple test program to compare haXe style js output with dart version:
// https://gist.github.com/1277224
// compile: haxe -main HelloHaxeTest -js test.js
class HelloHaxeTest {
static function main() {
trace("Hello, HaXer!");
}