Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env Rscript
app.name = "My App"
# file you gave source-map-explorer
# source-map-explorer 1.0.1/bundle.js --tsv > bundle-1.0.1.tsv
# source-map-explorer 1.5.0/bundle.js --tsv > bundle-1.5.0.tsv
asset.file = "bundle.js"
before.version = "1.0.1"
before.file = "bundle-1.0.1.tsv"
before.description = "1.0.1 (Jun 01)"
/**
* Create error with caused by and formatted stack trace while preserving
* the laziness of the stack trace serialization.
*/
function createErrorWithCausedBy(name, message, causedBy) {
const error = new Error(message);
error.name = name;
if (Error.captureStackTrace) {
// hides createErrorWithCausedBy from the stack
Error.captureStackTrace(error, createErrorWithCausedBy);
❯ ./out/x64.optdebug/d8 --allow-natives-syntax teststack.js
DebugPrint: 0x2bf167d0b3f9: [JS_ERROR_TYPE]
- map: 0x2bf153b4a549 <Map(HOLEY_ELEMENTS)> [FastProperties]
- prototype: 0x2bf15ffc62e1 <Object map = 0x2bf153b40fe9>
- elements: 0x2bf156880c21 <FixedArray[0]> [HOLEY_ELEMENTS]
- properties: 0x2bf156880c21 <FixedArray[0]> {
#stack: 0x2bf1946002f9 <AccessorInfo> (const accessor descriptor)
0x2bf156884a71 <Symbol: (stack_trace_symbol)>: 0x2bf167d0b619 <FixedArray[1]> (const data field 0)
}
0x2bf153b4a549: [Map]
// requires strict mode
// set false to minimize out runtime checks
const DEBUG = true;
export const enum TagTypes {
A,
B,
// C
/* adding this will cause Tag and unreachable to Error
// Monomorphic wrapper for polymorphic value
wrapper = {
type,
value
}
// CheckMap wrapper for .type lookup monomorphic
if (wrapper.type === 1) {
// CheckMap value for .somefield lookup monomorphic because in branch for one type
wrapper.value.somefield
// Copyright 2019 Kris Selden BSD 2-CLAUSE LICENSE
// math used is public domain just dont copy my code without giving credit.
// @ts-check
/**
* @typedef {{get(U: number, n1: number, n2: number): number; set(U: number, n1: number, n2: number, count: number): void;}} ICache
*/
x <- c(...) # samples
# for fitdist
suppressWarnings(library(fitdistrplus))
# for llog3 and lnorm3
suppressWarnings(library(FAdist))
print_ks_test <- function (x, dist, args) {
print(do.call(function (...) {
ks.test(x, paste0("p", dist), ...)
hodges_lehmann_location_shift_estimate <- function (x, y, conf.level) {
nx <- length(x)
ny <- length(y)
# https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_npar1way_a0000000201.htm
alpha <- 1 - conf.level
# qnorm in R is the https://en.wikipedia.org/wiki/Probit
# this is also using the https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test#Normal_approximation_and_tie_correction
Ca <- floor(nx * ny / 2 - qnorm(1 - alpha / 2) * sqrt(nx * ny * (nx + ny + 1) / 12))
m <- nx * ny
U <- vector(mode = "numeric", length = m)
const { EventEmitter } = require("events");
// Imagine your reading a stream of events from a socket
// and a data chunk event contains more than one event
// how do you adapt that one event to multiple events
// in a way that will prevent race conditions in async/await
// code?
//
// For example say you are waiting for a frame loaded event, then waiting
// loaded event of a child of that frame conditionally based on the
extern crate hyper;
extern crate tls_api;
extern crate tls_api_openssl;
extern crate tokio_tls_api;
use futures::{Future, Stream};
use hyper::server::conn::{AddrIncoming, Http};
use hyper::service::service_fn_ok;
use hyper::{Body, Request, Response};
use tls_api::TlsAcceptorBuilder;
use tokio_tls_api::accept_async;