Skip to content

Instantly share code, notes, and snippets.

View aztack's full-sized avatar
🎯
Focusing

Wang Weihua aztack

🎯
Focusing
View GitHub Profile
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)]);
@aztack
aztack / promise_monad.md
Created June 3, 2020 10:16 — forked from VictorTaelin/promise_monad.md
async/await is just the do-notation of the Promise monad

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing

@aztack
aztack / fxn.js
Created March 24, 2020 02:56 — forked from denizozger/fxn.js
Ramda cheatsheet
// Replace this:
for (const value of myArray) {
console.log(value)
}
// with:
forEach(value => console.log(value), myArray)
const double = x => x * 2
map(double, [1, 2, 3])
@aztack
aztack / github-emojis.md
Created July 4, 2019 16:41 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@aztack
aztack / popup_draggable.html
Created April 27, 2019 04:45 — forked from Aymkdn/popup_draggable.html
Draggable DIV cross-browser (from IE8) with pure JavaScript
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="popup" style="background-color:green;position:absolute;top:0px;left:0px;width:250px;height:250px;z-index:9999;box-shadow: 6px 6px 5px #888888;border-radius:6px;border:1px solid #4f4f4f;">
<div id="popup_bar" style="width:100%;background-color:#aaff66;position:relative;top:0;border-radius:6px 6px 0 0; text-align:center;height:24px;cursor:move">Title</div>
<p>Content of the popup</p>
</div>
</body>