Skip to content

Instantly share code, notes, and snippets.

Kris Selden krisselden

Block or report user

Report or block krisselden

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View tag.ts
// 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
View monomorphic_wrapper.js
// 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
View ustat_exact.js
// 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
*/
View shifted_log_logistic.R
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), ...)
View hodges_lehmann_location_shift_estimate.R
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)
View node_event_stream.js
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
View hyper-http2.rs
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;
View build.js
#!/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 Mar 29, 2019 — forked from raycohen/0-Overview.md
`@` as means argument to the template not property
View blog-post-at-lookup.hbs
<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 Mar 26, 2019
merge repo into monorepo at prefix with history
View merge-repo.sh
#!/usr/bin/env bash
remote_name=my-repo
remote_url=git@github.com: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
You can’t perform that action at this time.