Skip to content

Instantly share code, notes, and snippets.

View JLChnToZ's full-sized avatar

Jeremy Lam aka. Vistanz JLChnToZ

View GitHub Profile
@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 / SelectReferencesUtils.cs
Last active October 24, 2018 10:32
Utility script for selecting the reference on the scene by the selected project assets in Unity.
using System;
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using UnityObject = UnityEngine.Object;
public static class SelectReferencesUtils {
[MenuItem("Assets/Select Intances On Scene", false, 30)]
static void SelectInstances() {
Selection.objects = GetReferencesOfAsset(Selection.objects);
@JLChnToZ
JLChnToZ / BMS.cs
Last active November 8, 2016 03:01
A Generic BM98 Format Loader and Runner for XNA. Buggy stuff and not accurate. See https://github.com/JLChnToZ/Bemusilization for newer implementations.
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
@JLChnToZ
JLChnToZ / runscript.js
Created August 13, 2016 04:18
Similar to eval(), but it is safe to be called in strict mode and will run the code asynchronously (Nothing will be returned).
// Similar to eval(), but it is safe to be called in strict mode and will
// run the code asynchronously (Nothing will be returned).
// Available only in HTML5 DOM.
function runScript(script) {
if(!script) return;
// Create a temporary blob that contains the script string and
// add a script tag at the end of the document to contain that blob.
var blob = new Blob([script.toString()], { type: 'text/javascript' });
var url = URL.createObjectURL(blob);
@JLChnToZ
JLChnToZ / SelfDestructor.cs
Last active September 10, 2016 13:05
Simple script which will self destruct after executing.
using System;
using System.IO;
using System.Diagnostics;
using System.Reflection;
namespace SelfDestruct {
public class SelfDestructor {
const string batScript = "@echo off\r\n" +
":trydelete\r\n" +
"echo \"%~f1\">\"%~f1\"\r\n" +
@JLChnToZ
JLChnToZ / selfexpand.bat
Created September 10, 2016 08:09
Self expanding batch file
@echo off
echo "Self Expanding"
type %~f0 >> %~f0
rem The empty line at the end is important, or it will not works
@JLChnToZ
JLChnToZ / ColorMatrixCorrection.cs
Last active December 22, 2017 12:39
Unity rendering post processor which corrects the color with a color matrix.
using UnityEngine;
[ExecuteInEditMode, RequireComponent(typeof(Camera))]
public class ColorMatrixCorrection: MonoBehaviour {
public Matrix4x4 colorMatrix = Matrix4x4.identity;
public Vector4 baseColor;
private Material material;
private void Awake() {
material = new Material(Shader.Find("Hidden/ColorMatrixCorrection"));
@JLChnToZ
JLChnToZ / gachca-probs-research.markdown
Last active October 30, 2021 04:10
gachca-probs-research.markdown

有關概率和人品的研究與實作筆記

Jeremy Lam aka. JLChnToZ

前言

我寫這篇文章的原因主要是因為我看到現今的抽卡系統不夠「公平」,故此略為研究一下到底如何使抽卡類系統能夠做得更理想。

一般而言,玩家都會覺得抽不抽到想要的卡均是「人品」作祟,經常抽到稀有品稱為「歐洲人」、抽不到的則是「非洲人」,因此下面在描述各系統的同時亦會探討一下如何更能反映「人品」。