Skip to content

Instantly share code, notes, and snippets.

View aztack's full-sized avatar
🎯
Focusing

Wang Weihua aztack

🎯
Focusing
View GitHub Profile
@aztack
aztack / stack-vm.js
Created March 28, 2022 07:55 — forked from DmitrySoshnikov/stack-vm.js
Educational Stack-based Virtual Machine
/**
* Educational Stack-based VM.
*
* See also:
* - More complex example with recursion: https://gist.github.com/DmitrySoshnikov/afda459222e96e6002ac
* - Register-based VM example: https://gist.github.com/DmitrySoshnikov/6407781
*
* by Dmitry Soshnikov <[email protected]>
* http://dmitrysoshnikov.com
* MIT Stye License (C) 2015
@aztack
aztack / Effects.js
Created January 4, 2022 06:42 — forked from unktomi/Effects.js
/**
* Algebraic Effects and Handlers as in <a href='http://www.eff-lang.org/'>Eff</a>
*/
'use strict'
//
// Note:
// new Continuation() - returns the current function's continuation.
//
/**
* DERIVING THE Y COMBINATOR IN 7 EASY STEPS
*
* Ionut G. Stan | [email protected] | http://igstan.ro | http://twitter.com/igstan
*
*
* The Y combinator is a method of implementing recursion in a programming
* language that does not support it natively (actually, it's used more for
* exercising programming brains). The requirement is the language to support
* anonymous functions.
@aztack
aztack / checker_mod.ts
Created July 26, 2021 03:09 — forked from hackape/checker_mod.ts
Answer to Stack Overflow Question: "How can I see how TypeScript computes types?"
// https://github.com/microsoft/TypeScript/blob/ba5e86f1406f39e89d56d4b32fd6ff8de09a0bf3/src/compiler/checker.ts
// 1. add this line to ln:3
export const _conditionalTypes: any = {}
// 2. then replace ln:12303 to ln:12360
function trackConditionalType() {
// one time stuff
COOKIE="Cookie: thinkjs=______;" # 使用浏览器登录之后拿 cookie
VIP="________" # host ip
RESOLVE="--resolve ppt.baomitu.com:443:$VIP"
list_json=$(curl $RESOLVE -s -H "$COOKIE" "https://ppt.baomitu.com/api/slide/list?page=1&epage=500&tag_id=-1")
raw_js=`echo "console.log((" $list_json ").data.data.map(item => item.slide_title.trim().replace(/\s{2,}/g, ' ') + '#' + item.slide_id).join('\n'))"`
data=`node -e "$raw_js"`
dir_name="./ppt-baomitu"
rm -rf $dir_name
mkdir $dir_name
@aztack
aztack / launch.json
Created May 23, 2021 09:13 — forked from cecilemuller/launch.json
Run ts-node in VSCode Debugger
{
"version": "0.2.0",
"configurations": [
{
"name": "Example",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
@aztack
aztack / supplant.js
Created January 5, 2021 03:31 — forked from pbroschwitz/supplant.js
supplant - Crockford
/**
* supplant() does variable substitution on the string. It scans through the string looking for
* expressions enclosed in { } braces. If an expression is found, use it as a key on the object,
* and if the key has a string value or number value, it is substituted for the bracket expression
* and it repeats.
*
* Written by Douglas Crockford
* http://www.crockford.com/
*/
String.prototype.supplant = function (o) {
@aztack
aztack / WebGL-WebGPU-frameworks-libraries.md
Created August 10, 2020 11:26 — forked from dmnsgn/WebGL-WebGPU-frameworks-libraries.md
A collection of WebGL and WebGPU frameworks and libraries

A non-exhaustive list of WebGL and WebGPU frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are wip/outdated/not maintained anymore.

Engines and libraries

  • three.js: JavaScript 3D library
  • stack.gl: an open software ecosystem for WebGL, built on top of browserify and npm.
  • PixiJS: Super fast HTML 5 2D rendering engine that uses webGL with canvas fallback
  • Pex: Pex is a javascript 3d library / engine allowing for seamless development between Plask and WebGL in the browser.
  • Babylon.js: a complete JavaScript framework for building 3D games with HTML 5 and WebGL
  • Filament: Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS and WASM/WebGL
  • ClayGL: A WebGL graphic library
@aztack
aztack / jsc.swift
Created August 4, 2020 11:01 — forked from bellbind/jsc.swift
[swift4][macos] commandline REPL for JavaScriptCore with toplevel await
#!/usr/bin/env swift
// REPL for JavaScriptCore (for arrow keys, use rlwrap command)
import JavaScriptCore
class Timeout: NSObject, JSExport {
let item: DispatchWorkItem
init(_ item: DispatchWorkItem) {self.item = item}
}
func installBuiltins(_ ctx: JSContext) {
@aztack
aztack / promise-is-resolved.js
Created July 13, 2020 04:44 — forked from tyru/promise-is-resolved.js
Check whether a promise is finished / resolved / rejected
function delay(msec, value) {
return new Promise(done => window.setTimeout((() => done(value)), msec));
}
function isResolved(promise) {
  return Promise.race([delay(0, false), promise.then(() => true, () => false)]);
}
function isRejected(promise) {
  return Promise.race([delay(0, false), promise.then(() => false, () => true)]);