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 Queue = () => { | |
let idle = true; | |
const stack = [], | |
fx = (...job) => { | |
stack.push(...job); | |
if(idle) | |
(async () => { | |
idle = false; | |
while(stack.length) | |
await stack.shift()(); |
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
// Calendar for month `m` of the year `y` with Sunday as first day of week | |
const calS = (y,m) => { | |
let[r,d,w,l]=[[],1,0,!(y%4)-!(y%1e2)+!(y%4e2)], | |
c=((0|23*m/9)+(m<3?y--:y-2)+5+(0|y/4)-(0|y/1e2)+(0|y/4e2))%7; | |
for(;d<29+(0x3bbeecc+16*l>>m*2&3);++d,c=++c%7,w+=!c) | |
(r[w]||(r[w]=[,,,,,,,]))[c]=d; | |
return r | |
} | |
// Calendar for month `m` of the year `y` with Monday as first day of week |
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 getSelector(el){ | |
let nodes = [],c,e,d=el.ownerDocument,h=d.documentElement; | |
do{if (el.id){ nodes.push(`#${el.id}`); break; | |
}else{ if (el==h) c=0; else for (c=1,e=el;e=e.previousElementSibling;c++); | |
nodes.push(c?`:nth-child(${c})`:el.tagName.toLowerCase()); | |
} } while ((el=el.parentNode)&&el!=d); return nodes.reverse().join` > `; | |
} |
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 inside(point, vs) { | |
// ray-casting algorithm based on | |
// https://wrf.ecse.rpi.edu/Research/Short_Notes/pnpoly.html/pnpoly.html | |
// https://stackoverflow.com/questions/22521982/check-if-point-is-inside-a-polygon/29915728#29915728 | |
// https://github.com/substack/point-in-polygon | |
var x = point[0], y = point[1]; | |
var inside = false; | |
for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) { |
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
// ==UserScript== | |
// @name Stackoverflow dates | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Stackoverflow dates outdate marker | |
// @author You | |
// @include /^https:\/\/(.+\.)?stackoverflow\.com/ | |
// @icon https://www.google.com/s2/favicons?domain=stackoverflow.com | |
// @grant none | |
// ==/UserScript== |
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 send(method, url, headers = {}, data = null) { | |
return new Promise((resolve, reject) => { | |
console.log(data); | |
const xhr = new XMLHttpRequest(); | |
xhr.onload = () => resolve(xhr); | |
xhr.onerror = error => reject(error); | |
xhr.open(method, url, true); | |
console.log(xhr); | |
Object.entries(headers).forEach(([header, value]) => xhr.setRequestHeader(header, value)); | |
xhr.send(data); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
/** @format */ | |
/** | |
* @interface | |
* @name RequestParams | |
* @property {string} url адрес отправки | |
* @property {string} method метод | |
* @property {string} responseType | |
* @property {array} data | |
* @property {object} headers | |
* @property {function} uploadProgress |
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 arrayToBase64(array) { | |
let base64 = ''; | |
const encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | |
const arrayLength = array.byteLength; | |
const remainder = arrayLength % 3; | |
const mainLength = arrayLength - remainder; | |
let a, b, c, d; | |
let chunk; |
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
<!-- @format --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>CodePen - CSS Glitched Text</title> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" /> | |
<style> |