Skip to content

Instantly share code, notes, and snippets.

@YellowAfterlife
YellowAfterlife / wpeditor.part.css
Created September 8, 2014 17:52
WP Editor fix for WordPress 4.0
/* wpeditor.css, line 240: */
.CodeMirror {
height:auto !important;
width:100%;
}
.wp-editor-container .CodeMirror {
width:100% !important;
}
.wp-editor-container .CodeMirror-scroll {
border:none;
static function tryNormal() {
var r;
try {
r = 'normal';
} catch (_:Dynamic) {
r = null;
}
return r;
}
static function tryCompact() {
function Main_Main.tryNormal()
local r
local try, catch = pcall(function ()
r = "normal"
end);
if (try == false) then
local _ = catch;
r = nil
end
return r
function printTry(e1:haxe.macro.TypedExpr, catches: Array<{ v : haxe.macro.TVar, expr : haxe.macro.TypedExpr }>)
{
// TODO catch other types of exceptions
// getting last (e:Dynamic) catch:
var _dynCatch = catches.pop(), _tabs;
// try-block:
var s = 'local try, catch = pcall(function ()';
_tabs = tabs; tabs += tabString;
var tryBlock = printExpr(e1);
@YellowAfterlife
YellowAfterlife / assign-operator.lua
Created September 17, 2014 14:29
Comparisons for what is "var2 = (var1 = value)" in other languages.
function set_field(t, f, v)
t[f] = v
return v
end
local n = 10000000
local t = { }
local q
local p
-- Direct:
q = os.clock()
/// Create:
globalvar mouse_x0, mouse_y0, mouse_x1, mouse_y1, mouse_dx, mouse_dy;
mouse_x1 = mouse_x
mouse_y1 = mouse_y
mouse_dx = 0
mouse_dy = 0
/// Step:
mouse_x0 = mouse_x1; mouse_x1 = mouse_x
mouse_y0 = mouse_y1; mouse_y1 = mouse_y
@YellowAfterlife
YellowAfterlife / ImplementsHaxe.java
Created September 23, 2014 20:24
This is what you have to do to interface from Java with a Haxe interface, as they all implement IHxObject for no particular reason.
import java.lang.Object;
import java.lang.String;
public class JavaClass implements HaxeInterface {
// ...
// Dummy IHxObject implementation:
public boolean __hx_deleteField(String f) { return false; }
public Object __hx_lookupField(String f, boolean e, boolean c) { return null; }
public double __hx_lookupField_f(String f, boolean e) { return 0.0; }
public Object __hx_lookupSetField(String f, Object v) { return null; }
// Experimenting with custom JSON serialization.
// Things that annoy me in existing implementation are:
// * Ordering: Since haxe.Json takes dynamic objects, field order cannot be warranted.
// If resulting JSON has to be viewed/edited manually, uncertain order is no help.
// * Readability: You have no control over how contents are written. Prettyprint gets bulky fast.
// * Typing: JSON nodes are, by definition, dynamic objects, which means that you'll most
// likely have to implement an extra I/O layer with "data from class N" typedefs.
// * Efficiency: Dynamic objects and arrays are read only to (most often) be thrown again later.
//
// So here I'm working on a library that solves a fair of these problems by providing
package openfl.state;
import openfl.events.Event;
import openfl.events.KeyboardEvent;
import openfl.Lib;
/**
* Provides a simple interface to get keyboard state.
* @author YellowAfterlife
*/
class Keyboard {
@YellowAfterlife
YellowAfterlife / SpelunkySD.txt
Created October 24, 2014 18:12
Spelunky SD readme snip (October 2014)
_____________________
/ Spelunky SD
A Spelunky Classic mod
by YellowAfterlife
This is a modification and expansion of "Spelunky Classic" by Derek Yu.
It changes and improves a number of things in the game, most notably adding
2-player cooperative online multi-player support.
Useful links: