Skip to content

Instantly share code, notes, and snippets.

@bmeck
bmeck / harness.js
Created Mar 17, 2021
bradley needed to dump this devtools type tracer PoC somewhere
View harness.js
function foo(x, y) {
return Object;
}
const { stop } = trace();
new foo([1], new Date());
stop();
// boilerplate after this
View lone surrogates - split codepoint problem.sh
# see the replacement character ( Buffer.from(new TextEncoder().encode('\u{fffd}')) ) instead
# https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character
node -e 'process.stdout.write("👌"[0]);setTimeout(() => {process.stdout.end("👌"[1]); process.exit()},3e3)' |
node -e '(async (s = "") => {for await (const a of process.stdin) {console.log(a); s+= a}; console.log(s)})()'
View node-policies.json
{
"type": "object",
"title": "Node.js Policy Manifest",
"description": "https://nodejs.org/api/policy.html",
"definitions": {
"cascade": {
"defaultSnippets": [
{
"label": "Allow scope fall through.",
"body": true
View total-pages.txt
This file has been truncated, but you can view the full file.
http://0-chromosome.hatenablog.jp/
http://0.lifecell.com.ua/
http://002tousan.seesaa.net/
http://00monochrome.blog32.fc2.com/
http://00room.blog.fc2.com/
http://0301244.hatenablog.com/
http://0316shank.hatenablog.com/
http://03310711.blog59.fc2.com/
@bmeck
bmeck / hmr.js
Created Mar 20, 2020 — forked from georges-gomes/hmr.js
Hot module reload prototype
View hmr.js
import inspector from "inspector";
const url2scriptid = new Map<string, string>();
const session = new inspector.Session();
session.connect();
setupDebugger();
function setupDebugger() {
@bmeck
bmeck / machine.js
Last active Feb 20, 2020
Generated by XState Viz: https://xstate.js.org/viz
View machine.js
const loop = Machine({
context: { x: 3 },
initial: 'while (x > 0)',
states: {
"while (x > 0)": {
on: {
EVAL: [
{
target: "x--",
cond(ctx, evt) {
@bmeck
bmeck / machine.js
Last active Feb 20, 2020
Generated by XState Viz: https://xstate.js.org/viz
View machine.js
const workflow = Machine({
id: "workflow",
initial: "running",
states: {
running: {
id: "file",
type: "parallel",
states: {
upload: {
initial: "idle",
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View show-clean.js
async function doSomething() {
await timeout(2000);
}
function timeout(ms) {
return new Promise((res,rej) => setTimeout(rej,ms));
}
Promise.race([
doSomething(),
timeout(1000)
View minimal.log
--- Raw source ---
(thisArg, ...args) => {
return apply(fn, thisArg, args);
};
--- Optimized code ---
optimization_id = 0
source_position = 98
kind = OPTIMIZED_FUNCTION
name = cached