Skip to content

Instantly share code, notes, and snippets.

View 0b1kn00b's full-sized avatar

0b1kn00b

View GitHub Profile
@mjg123
mjg123 / ajax.cljs
Created July 21, 2011 22:43
How to make a json(p) request from ClojureScript using jQuery
(def jquery (js* "$"))
(defn show [msg]
(let [data-as-json ((js* "JSON.stringify") msg nil 4)]
((js* "alert") data-as-json)))
(defn make-js-map
"makes a javascript map from a clojure one"
[cljmap]
(let [out (js-obj)]
@jgranick
jgranick / gist:1763850
Created February 8, 2012 01:05
NMML File Specification
<?xml version="1.0" encoding="utf-8"?>
<project>
<!-- <meta />
Use meta nodes to set metadata for your application. The description is ignored
on most targets, but is useful for packaging like Chrome Apps or Opera Widgets.
For compatibility with Android and webOS, the package name must include at least
@back2dos
back2dos / Main.hx
Created September 19, 2012 06:42
Statically typed metadata (compile with -lib tink_macros --macro TagChecker.use())
package ;
import haxe.rtti.Meta;
@:tag('foo') typedef Foo = {
?bar:String,
?baz:Int
}
@:tag typedef Bar = Dynamic;
@Simn
Simn / Main.hx
Created November 3, 2012 16:59
Function-based specialization wizardry in haxe3
class Main {
static function main() {
trace(process(12)); // 24
trace(process("Hello world")); // HELLO WORLD
}
@:generic static function process<T>(t:T):T {
return throw "unknown type: " + t;
}
@nadako
nadako / Globals.hx
Last active February 7, 2021 06:43
A small hack to make JS global variable easily available in Haxe
extern class Globals
{
public static var context(get, never):Context;
inline static function get_context():Context return untyped __js__("context");
}
extern class Context
{
public function doStuff():Void;
}
@martinwells
martinwells / gist:5980517
Created July 12, 2013 00:43
Simple Haxe logging with colors
/**
Simple, colorful logging!
Setup
=====
Somewhere really early in your code do a:
Log.init();
This will setup the logger methods and coloring stuff.
Logging
@nadako
nadako / SchemaTypeBuilder.hx
Last active October 31, 2020 03:34
JSON-schema type builder prototype.
#if macro
import haxe.macro.Context;
import haxe.macro.Expr;
class SchemaTypeBuilder
{
public static function build(ref:String):haxe.macro.Type
{
var schema = haxe.Json.parse(sys.io.File.getContent(ref));
var type:ComplexType = parseType(schema);
import haxe.macro.Expr;
class FTW
{
public static function build()
{
return haxe.macro.Context.getBuildFields().map(transformField);
}
static function transformField(field:Field)
@dpeek
dpeek / gist:7803958
Created December 5, 2013 11:41
Building Haxe for Android
$ mkdir haxe-droid && cd haxe-droid
$ git clone https://github.com/vouillon/ocaml-android.git
$ git clone https://github.com/HaxeFoundation/haxe.git
$ http://dl.google.com/android/ndk/android-ndk-r9b-darwin-x86.tar.bz2
$ tar -vjxf android-ndk-r9b-darwin-x86.tar.bz2 && rm android-ndk-r9b-darwin-x86.tar.bz2 && mv android-ndk-r9b android-ndk
$ wget http://caml.inria.fr/pub/distrib/ocaml-4.01/ocaml-4.01.0.tar.gz
$ tar -xzf ocaml-4.01.0.tar.gz && rm ocaml-4.01.0.tar.gz && mv ocaml-4.01.0 ocaml-src
@waneck
waneck / Repl.hx
Last active September 13, 2020 14:04
Very simple Haxe REPL
/*
Copyright (c) 2014 Cauê Waneck
All rights reserved.
Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
advertising materials, and other materials related to such
distribution and use acknowledge that the software was developed
by the <organization>. The name of the