This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const path = require('path'); | |
const child_process = require('child_process'); | |
main(); | |
async function main() { | |
await yarnRun( | |
'pbjs', | |
'-t', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
remote_name=my-repo | |
[email protected]:my-org/my-repo.git | |
remote_branch=master | |
prefix=packages/$remote_name/ # trailing slash is important | |
git remote add $remote_name $remote_url | |
git fetch $remote_name | |
# create a merge commit with our side winning as the strategy but stop before committing it | |
git merge -s ours --allow-unrelated-histories --no-commit $remote_name/$remote_branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Readable } = require("stream"); | |
class ReadableTest extends Readable { | |
constructor() { | |
super({ highWaterMark: 256 }); | |
this.source = Buffer.from(`abcdefghijklmnopqrstuvwxyz.. | |
The quick brown fox jumps over the lazy dog. | |
The quick brown fox jumps over the lazy dog. | |
The quick brown fox jumps over the lazy dog. | |
The quick brown fox jumps over the lazy dog. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const chromeFinder = require("chrome-launcher/dist/chrome-finder"); | |
const { getPlatform } = require("chrome-launcher/dist/utils"); | |
const execa = require("execa"); | |
const { Transform } = require("stream"); | |
const { inspect } = require("util"); | |
let seq = 0; | |
function eachMessage() { | |
/** @type {Buffer[]} */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bindingsMap = new WeakMap(); | |
function bound() { | |
return (target, key, descriptor) => { | |
const { enumerable, configurable, value } = descriptor; | |
return { | |
enumerable, | |
configurable, | |
get() { | |
let bindings = bindingsMap.get(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bound() { | |
return (target, key, descriptor) => { | |
const symbol = Symbol(key); | |
const { enumerable, configurable, value } = descriptor; | |
return { | |
enumerable, | |
configurable, | |
get() { | |
let fn = this[symbol]; | |
if (fn === undefined) { |