Skip to content

Instantly share code, notes, and snippets.

View JLChnToZ's full-sized avatar
🥽
From game to XR experience

Jeremy Lam aka. Vistanz JLChnToZ

🥽
From game to XR experience
View GitHub Profile
@JLChnToZ
JLChnToZ / Christmas.xml
Last active August 29, 2015 14:01
Sample file for block editor test. (http://gh.jlctz.tk/BlockEditorTest/)
<xml>
<block type="variables_set" id="44" inline="false" x="86" y="30">
<field name="VAR">a</field>
<value name="VALUE">
<block type="math_number" id="63">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="variables_set" id="102" inline="false">
@JLChnToZ
JLChnToZ / compare.coffee
Last active August 29, 2015 14:03
Deep compare 2 JavaScript objects
compare = (->
compareByType =
"array": (a, b) ->
return false if a.length isnt b.length
return false for i in [0...a.length] when not equals a[i], b[i]
true
"object": (a, b) ->
return false for i of a when not (b.hasOwnProperty i) or not equals a[i], b[i]
return false for i of b when not a.hasOwnProperty i
@JLChnToZ
JLChnToZ / mccolor.coffee
Last active August 29, 2015 14:03
Minecraft Color Formatting JQuery Plugin (Supports debug console too)
# Minecraft Color Formatting JQuery Plugin
# (c) JLChnToZ 2014
(($) ->
MCColors = [
0, 10, 160, 170
2560, 2570, 4000, 2730
1365, 1375, 1525, 1535
3925, 3935, 4085, 4095
]
rndstr = (len, chars) ->
@JLChnToZ
JLChnToZ / beats.js
Created August 17, 2014 18:19
Swatch Internet Time in JavaScript
Date.prototype.getBeats = function() {
return (this / 864e2 + 1e3 / 24) % 1e3;
};
@JLChnToZ
JLChnToZ / misc.coffee
Last active August 29, 2015 14:06
I don't know when it will be used, but just write it out...
Object::seek = (tree) ->
tree = tree() if typeof tree is "function"
tree = tree.split "." if typeof tree is "string"
tree = [tree] unless tree instanceof Array
iterate = @
iterate = iterate[i] for i in tree
iterate
Object::override = (tree, newStuff, noExec) ->
tree = tree() if typeof tree is "function"
@JLChnToZ
JLChnToZ / autoadjusttimer.js
Created November 9, 2014 04:19
Auto Adjust Timer Function, does not 100% guarantee accurate.
(function(root) {
if(!root) root = {};
var nextID = 0, timers = [];
root.setAutoAdjustInterval = function(callback, interval, timeKeeperFunc, frameTheshold) {
if(!timeKeeperFunc || typeof timeKeeperFunc != "function")
timeKeeperFunc = Date.now;
if(!frameTheshold || typeof frameTheshold != "number")
frameTheshold = 1000 / interval;
var timeDiff,
thisTS,
@JLChnToZ
JLChnToZ / TST.cs
Created November 25, 2014 16:19
Uncompilable ToString()
public static class TST {
public static string TestToString() {
return "ToString() test"
.ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString()
.ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString()
.ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString()
.ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString()
.ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString()
@JLChnToZ
JLChnToZ / MultiDimenIterator.cs
Created December 7, 2014 12:22
Multi-dimensional enumerable iterators (Up to 5 dimensional)
using System;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// Contains muti dimensional iterators.
/// </summary>
public static class MultiDimenIterator {
/// <summary>
@JLChnToZ
JLChnToZ / Game1.cs
Created August 13, 2013 07:27
Burn the falling pork game (Kinect ver.) source code (messy stuff)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Kinect;
using libZPlay;
MCFormatToHTML = (src) ->
src = src.replace /&/g, "&amp;"
src = src.replace /</g, "&lt;"
src = src.replace />/g, "&gt;"
src = src.replace /"/g, "&quot;"
src = src.replace /\s/, "&nbsp;"
src = src.replace /\n/, "<br />"
colors = ["000", "00A", "0A0", "0AA", "A00", "A0A", "FA0", "AAA", "555", "55F", "5F5", "5FF", "F55", "F5F", "FF5", "FFF"]
shadowColors = ["000000", "00002A", "002A00", "002A2A", "2A0000", "2A002A", "2A2A00", "2A2A2A", "151515", "15153F", "153F15", "153F3F", "3F1515", "3F153F", "3F3F15", "3F3F3F"]
color = "000"