Skip to content

Instantly share code, notes, and snippets.

[[
01234567890123456789012345678901234567890123456789012345678901234567890123456789
]]
-- NOTE: requires 'LPEG' module
local re = require're'
local assert = assert
local min, max = math.min, math.max
-- PEG Grammar 1:
private void Start()
{
_mousePositions = new Vector2[TimeFliesLikeAnArrow.Length];
for (var i = 0; i < _mousePositions.Length; i++)
{
var ii = i;
_subscriptions.Add(
// Magic happens here:
RxHost.Instance.GUIEvents
.Where(e => e.type == EventType.mouseMove)
@zoon
zoon / gist:700314
Created November 15, 2010 12:53
Unity3D Input: OnGUI vs.Update.
using System.Threading;
using UnityEngine;
// [ExecuteInEditMode]
public class InputTest : MonoBehaviour
{
private float _delay;
private float _fps;
private float _fpsTime;
package;
/**
* Xorshift preudorandom number generator for Haxe.
* Reference: http://en.wikipedia.org/wiki/Xorshift
*/
class Xorshift
{
inline public static var INT_MAX:Int = 0x7FFFFFFF; // (2^31 - 1)
inline public static var INT_MAXPLUSONE:Float = 2147483648.0;
@zoon
zoon / gist:876025
Created March 18, 2011 13:01
Property extraction macro
package ;
import haxe.macro.Expr;
import haxe.macro.Context;
class Test
{
public static var staticField:String = "hello";
public var intField:Int;
@zoon
zoon / gist:882558
Created March 23, 2011 03:22
Recursive alpha-renamer for 'this'
package ;
import haxe.macro.Context;
import haxe.macro.Expr;
using Lambda;
class Macros
{
public static var fresh(getFresh, null):String;
private static var _fresh:Int = 0;
(function () {
var path = basePath();
var swfs = listUrisRec(path, ["swf"]);
var logURI = path + "/swf_build_log.txt";
var errorsURI = path + "/swf_build_errors.txt";
var built = 0;
var notBuilt = 0;
createLog();
createErrorLog();
@zoon
zoon / _emacs.el
Last active March 10, 2016 05:56
my dot emacs
;; ver <2016-03-10 08:55AM>
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(blink-cursor-mode nil)
'(browse-url-browser-function (quote browse-url-default-windows-browser))
'(column-number-mode t)
'(current-language-environment "UTF-8")
https://www.siggraph.org/education/materials/HyperGraph/video/mpeg/mpegfaq/huffman_tutorial.html
A quick tutorial on generating a huffman tree
Lets say you have a set of numbers and their frequency of use and want to create a huffman encoding for them:
FREQUENCY VALUE
--------- -----
5 1
7 2
10 3