Skip to content

Instantly share code, notes, and snippets.

View petrvecera's full-sized avatar

Petr Vecera petrvecera

View GitHub Profile
@petrvecera
petrvecera / latest.js
Created January 12, 2023 12:56
RUM-all-browsers
(()=>{var e={296:(e,t,n)=>{var i=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,a=/^0o[0-7]+$/i,c=parseInt,s="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g,u="object"==typeof self&&self&&self.Object===Object&&self,f=s||u||Function("return this")(),d=Object.prototype.toString,l=Math.max,p=Math.min,h=function(){return f.Date.now()};function v(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function m(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==d.call(e)}(e))return NaN;if(v(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=v(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var n=o.test(e);return n||a.test(e)?c(e.slice(2),n?2:8):r.test(e)?NaN:+e}e.exports=function(e,t,n){var i,r,o,a,c,s,u=0,f=!1,d=!1,g=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function y(t){var n=i,o=r;return i=r=void 0,u=t,a=e.apply(o,n)}function _(e){return u=e,c=setTimeout(E,t),
@petrvecera
petrvecera / dateFns.ts
Created July 31, 2021 21:35
Fixed dateFns which doesn't include all locales
import {
getDay,
getYear,
getMonth,
getDate,
endOfMonth,
getHours,
getMinutes,
getSeconds,
addYears,
@petrvecera
petrvecera / throttle.js
Created May 19, 2021 15:26
Simple JS throttle function which ignores additional calls within the given timeframe
function throttle(callback, delay) {
let isThrottled = false;
function wrapper() {
if (isThrottled) {
return;
}
isThrottled = true;
callback.apply(this, arguments);
setTimeout(() => {
isThrottled = false;
@petrvecera
petrvecera / md5hash.html
Created July 12, 2019 11:19
Calculate MD5 hash of file without the need to download it ( it's still downloads, bust just in the browser)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>title</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.js"></script>
<script type="text/javascript">