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 geodistance(lat1,lon1,lat2,lon2){ | |
| const R = 6371e3; // in metres | |
| const φ1 = lat1 * Math.PI/180; // φ, λ in radians | |
| const φ2 = lat2 * Math.PI/180; | |
| const Δφ = (lat2-lat1) * Math.PI/180; | |
| const Δλ = (lon2-lon1) * Math.PI/180; | |
| const a = Math.sin(Δφ/2) * Math.sin(Δφ/2) + | |
| Math.cos(φ1) * Math.cos(φ2) * | |
| Math.sin(Δλ/2) * Math.sin(Δλ/2); |
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 detab(str) { | |
| return str.replaceAll(/^\s*|\s*$|(?<=(?:\n(\s*).*?)+)\1/g, ""); | |
| } | |
| // Test | |
| let query = ` | |
| SELECT | |
| 'table'.* | |
| FROM |
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 koi8rToUtf8 ( buf ) { | |
| if( buf instanceof ArrayBuffer ) { | |
| buf = new Uint8Array ( buf ); | |
| } | |
| if( ! Array.isArray ( buf ) ) { | |
| buf = [ ... buf ]; | |
| } | |
| const map = new Map ( [ | |
| [0x80,0x2500], [0x81,0x2502], [0x82,0x250C], [0x83,0x2510], | |
| [0x84,0x2514], [0x85,0x2518], [0x86,0x251C], [0x87,0x2524], |
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 cp1251ToUtf8(buf){ | |
| if(buf instanceof ArrayBuffer) buf = new Uint8Array(buf); | |
| if(!Array.isArray(buf)) buf = [...buf]; | |
| const map = new Map([ | |
| [128,1026], [129,1027], [130,8218], [131,1107], | |
| [132,8222], [133,8230], [134,8224], [135,8225], | |
| [136,8364], [137,8240], [138,1033], [139,8249], | |
| [140,1034], [141,1036], [142,1035], [143,1039], | |
| [144,1106], [145,8216], [146,8217], [147,8220], |
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 */ | |
| /** | |
| * | |
| * The principle of the algorithm is very simple. | |
| * | |
| * The module exports three functions: | |
| * | |
| * getTask() | |
| * The first function does not need any arguments. |
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 createWorker(callable) { | |
| const code = `onmessage=${callable.toString()}`; | |
| const blob = new Blob([code], { type: 'text/javascript' }); | |
| const url = URL.createObjectURL(blob); | |
| const worker = new Worker(url); | |
| URL.revokeObjectURL(url); | |
| return worker; | |
| } |
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 */ | |
| /** | |
| * Функция отчищает JPEG-картинку от метаданных | |
| * | |
| * @param {ArrayBuffer} buf буфер с изображением | |
| * @returns {Blob|null} | |
| */ | |
| function clearJpegMetadata(buf) { | |
| if (!(buf instanceof ArrayBuffer)) { |
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> |
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 */ | |
| /** | |
| * @interface | |
| * @name RequestParams | |
| * @property {string} url адрес отправки | |
| * @property {string} method метод | |
| * @property {string} responseType | |
| * @property {array} data | |
| * @property {object} headers | |
| * @property {function} uploadProgress |