Skip to content

Instantly share code, notes, and snippets.

Avatar
😕
shaving bytes and milliseconds. dependencies: {}

Leon Sorokin leeoniya

😕
shaving bytes and milliseconds. dependencies: {}
View GitHub Profile
View uplot-ws.js
let u;
const ws = new WebSocket("ws://127.0.0.1:6789/");
ws.onmessage = function(event) {
const data = JSON.parse(event.data);
switch (data.type) {
case 'ohlc':
let ohlc = [data.ts, data.o, data.h, data.l, data.c];
@leeoniya
leeoniya / binom-test.js
Created Apr 19, 2020 — forked from bellbind/binom-test.js
[javascript] [statistics](both welch's and student's) t-test implementations
View binom-test.js
/*
// binomial coefficient nCk
function binom(n, k) {
k = n - k < k ? n - k : k;
const b = [1].concat(Array.from(Array(k), _ => 0));
for (let i = 1; i <= n; i++) {
for (let j = i < k ? i : k; j > 0; j--) b[j] += b[j - 1];
}
return b[k];
}
@leeoniya
leeoniya / README.md
Created Apr 19, 2020 — forked from bluesmoon/README.md
Pseudo-Random number generator that follows a Normal or Log-Normal distribution.
View README.md

Marsaglia-polar.js

This script generates random numbers along a Normal or Log-normal distribution using the Marsaglia polar method.

There are four functions you can use:

  • normalRandom: Generate random numbers that follow a Normal distribution.
  • normalRandomInRange: Generate random numbers that follow a Normal distribution but are clipped to fit within a range
  • normalRandomScaled: Generate random numbers that follow a Normal distribution with a given mean and standard deviation
  • lnRandomScaled: Generate random numbers that follow a Log-normal distribution with a given geometric mean and geometric standard deviation
@leeoniya
leeoniya / plink-plonk.js
Created Feb 18, 2020 — forked from tomhicks/plink-plonk.js
Listen to your web pages
View plink-plonk.js
@leeoniya
leeoniya / twittermute.txt
Created Jan 25, 2020 — forked from IanColdwater/twittermute.txt
Here are some terms to mute on Twitter to clean your timeline up a bit.
View twittermute.txt
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@leeoniya
leeoniya / key.md
Created Dec 21, 2019 — forked from shobotch/key.md
Twitter (un)official Consumer Key
View key.md

Twitter Official Consumer Key

Twitter for Android

type:            PIN
Consumer key:    3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPhone

type:            PIN
Consumer key:    IQKbtAYlXLripLGPWd0HUA
View server.js
const http = require('http');
const port = 5000;
const fetch = require('node-fetch');
const requestHandler = (request, response) => {
fetch('http://localhost:3000/').then(r => r.text()).then(text => {
// console.log(text);
response.end(text);
});
}
View stats.js
function stats(arr) {
arr = arr.slice().sort();
var n = arr.length;
var sum = arr.reduce((acc, val) => acc + val, 0);
var prod = arr.reduce((acc, val) => acc * val, 1);
var amean = sum / n;
var gmean = Math.pow(prod, 1 / n);
var median = n % 2 === 0 ? (arr[n / 2 - 1] + arr[n / 2]) / 2 : arr[(n - 1) / 2];
var variance = 0;
var stddev = 0;
@leeoniya
leeoniya / letsencrypt_2017.md
Created Dec 31, 2017 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)
View letsencrypt_2017.md

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

View domvm-memleak-reduced.html
<!doctype html>
<html>
<head>
<script>
domvm = (function() { "use strict";
var doc = document;
var emptyObj = {};
var isArr = Array.isArray;
function VNode() {}
You can’t perform that action at this time.