Skip to content

Instantly share code, notes, and snippets.

😕
:\

Leon Sorokin leeoniya

Block or report user

Report or block leeoniya

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 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_2019.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() {}
View domvm-noleak.html
<!doctype html>
<html>
<head>
<script src="https://cdn.rawgit.com/leeoniya/domvm/3.x-dev/dist/nano/domvm.nano.js"></script>
</head>
<body>
<script>
// http://imgur.com/a/YATqh
// https://cdn.rawgit.com/leeoniya/6149d983cd128ca6ac7c06e9dd3bd80f/raw/fe86cef4cc97aad1b89ef685643afa8590763a66/domvm-memleak.html
View domvm-memleak.html
<!doctype html>
<html>
<head>
<script src="https://cdn.rawgit.com/leeoniya/domvm/3.x-dev/dist/nano/domvm.nano.js"></script>
</head>
<body>
<script>
// http://imgur.com/a/YATqh
var el = domvm.defineElement;
View svg2-href.html
<!doctype html>
<html>
<head>
<script src="https://rawgit.com/leeoniya/domvm/3.x-dev/dist/pico/domvm.pico.min.js"></script>
</head>
<body>
<style>
h1 {
font-size: 4em;
}
@leeoniya
leeoniya / gist:64c6d859e0ebd0a3f945f02669a9b624
Created Jul 2, 2017 — forked from micho/gist:728639
Throttle and debounce examples
View gist:64c6d859e0ebd0a3f945f02669a9b624
// Run the function as soon as it's called, but prevent further calls during `delay` ms
// Example: function.throttle(200) will only run function() once every 200 ms.
// Useful, for example, to avoid constant processing while typing in a live search box.
Function.prototype.throttle = function(delay) {
var fn = this
return function() {
var now = (new Date).getTime()
if (!fn.lastExecuted || fn.lastExecuted + delay < now) {
fn.lastExecuted = now
fn.apply(fn, arguments)
View new-factory9.html
<!doctype html>
<html>
<head></head>
<body>
<ul id='cycleResults'></ul>
<div id="result"></div>
<br>
<button id="btn">Run Tests</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.2/lodash.min.js"></script>
View new-factory8.html
<!doctype html>
<html>
<head></head>
<body>
<ul id='cycleResults'></ul>
<div id="result"></div>
<br>
<button id="btn">Run Tests</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.2/lodash.min.js"></script>
View new-factory7.html
<!doctype html>
<html>
<head></head>
<body>
<ul id='cycleResults'></ul>
<div id="result"></div>
<br>
<button id="btn">Run Tests</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.2/lodash.min.js"></script>
You can’t perform that action at this time.