Skip to content

Instantly share code, notes, and snippets.

View wonglok's full-sized avatar
🙏
Thank you Jesus for the new life

Wong Lok wonglok

🙏
Thank you Jesus for the new life
View GitHub Profile
@wonglok
wonglok / index.html
Created June 14, 2022 08:56 — forked from BlueMagnificent/index.html
Javascript 3D Physics Snippet Four
<html>
<head>
<meta charset="utf-8">
<title>JS 3D Physics</title>
<style>
body { margin: 0; }
</style>
</head>
<body>
<script src="js/three.js"></script>
@wonglok
wonglok / loadExt.js
Created January 28, 2020 00:37 — forked from Aymkdn/loadExt.js
To load JS and CSS files with vanilla JavaScript
// long version
function loadExt(files, after) {
var _this=this;
_this.files = files;
_this.js = [];
_this.head = document.getElementsByTagName("head")[0];
_this.after = after || function(){};
_this.loadStyle = function(file) {
var link = document.createElement("link");
link.rel = "stylesheet";
@wonglok
wonglok / functional-utils.js
Created August 1, 2019 01:02 — forked from bendc/functional-utils.js
A set of pure ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@wonglok
wonglok / jwtRS256.sh
Created July 12, 2019 03:15 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@wonglok
wonglok / gist:2431e73283f529b27fcae32ea8852118
Created May 11, 2019 03:46 — forked from lmccart/gist:2273a047874939ad8ad1
p5.js + p5.dom.js + clmtracker.js
<html>
<head>
<script src="clmtrackr.js"></script>
<script src="model_pca_20_svm.js"></script>
<script src="p5.js"></script>
<script src="p5.dom.js"></script>
<script>
var ctracker;
@wonglok
wonglok / loadimage.js
Created March 6, 2018 06:53 — forked from ahem/loadimage.js
Load and decode images with webworker
/* global createImageBitmap */
function loadImageWithImageTag(src) {
return new Promise((resolve, reject) => {
const img = new Image;
img.crossOrigin = '';
img.src = src;
img.onload = () => { resolve(img); };
img.onerror = () => { reject(img); };
});
@wonglok
wonglok / connectHTMLelements_SVG.png
Created November 26, 2017 10:07 — forked from alojzije/connectHTMLelements_SVG.png
Connect two elements / draw a path between two elements with SVG path (using jQuery)
connectHTMLelements_SVG.png
@wonglok
wonglok / wechat-browser-detect.js
Created October 18, 2015 00:34 — forked from loo2k/wechat-browser-detect.js
JavaScript 判断是否微信内置浏览器
// 使用 userAgent 判断是否微信内置浏览器
// 不推荐使用 用户可能会自行修改浏览器的 userAgent
if( navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1 || typeof navgator.wxuserAgent !== "undefined" ) {
return true;
}
// 使用微信 JS 对象判断是否微信内置浏览器
// 建议使用此方法进行判断
if( typeof WeixinJSBridge !== "undefined" ) {
return true;
@wonglok
wonglok / _.md
Created October 6, 2015 05:15 — forked from stevekinney/_.md
Lorenz Curve
// relies on Date.now() which has been supported everywhere modern for years.
// as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values
// if you want values similar to what you'd get with real perf.now, place this towards the head of the page
// but in reality, you're just getting the delta between now() calls, so it's not terribly important where it's placed
(function(){
// prepare base perf object