Skip to content

Instantly share code, notes, and snippets.

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;
#!/usr/bin/env node
const path = require('path');
const child_process = require('child_process');
main();
async function main() {
await yarnRun(
'pbjs',
'-t',
@krisselden
krisselden / blog-post-at-lookup.hbs
Last active March 29, 2019 19:36 — forked from raycohen/0-Overview.md
`@` as means argument to the template not property
<div class="blog-post">
<header>
<Avatar class="blog-post__avatar" @user={{@user}} />
<title>{{@title}}</title>
</header>
<p>
{{@body}}
</p>
</div>
@krisselden
krisselden / merge-repo.sh
Last active March 26, 2019 21:00
merge repo into monorepo at prefix with history
#!/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
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.
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[]} */
const bindingsMap = new WeakMap();
function bound() {
return (target, key, descriptor) => {
const { enumerable, configurable, value } = descriptor;
return {
enumerable,
configurable,
get() {
let bindings = bindingsMap.get(this);
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) {