Skip to content

Instantly share code, notes, and snippets.

View surma's full-sized avatar
🍑

Surma surma

🍑
View GitHub Profile
@surma
surma / findall_elements_deep.js
Last active October 25, 2020 16:41 — forked from ebidel/findall_elements_deep.js
Finds all elements on the page, including those within shadow dom — iterator version
/**
* Inspired by ebidel@ (https://gist.github.com/ebidel/1b418134837a7dde7d76ed36288c1d16)
* @author surma@
* License Apache-2.0
*/
function* collectAllElementsDeep(selector = '*', root = document.all) {
for (const el of root) {
if (!el.matches(selector))
continue;
@surma
surma / build.sh
Created March 29, 2018 17:25 — forked from anthumchris/build.sh
Emscripten WebAssembly Module.ready() Promise initialization similar to Module.onRuntimeInitialized
#!/bin/bash
docker run --rm -v $(pwd):/src trzeci/emscripten emcc \
-O0 `# leave uncompressed for example` \
-s WASM=1 \
-s EXPORTED_FUNCTIONS="['_hello']" \
-s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap']" \
-o emscripten-module.js \
--post-js module-post.js \
hello.c