This file contains 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
/** | |
* BarcodeDetector has an "Experimental" status. It sometimes doesn't work for no reason. | |
* | |
* @param {string} barcodeType only qr_code and pdf417 are supported | |
* @return {boolean} (async) If BarcodeDetector works or not | |
*/ | |
const isBarcodeDetectorWorking = (barcodeType) => { | |
return new Promise((resolve, reject) => { | |
if (typeof BarcodeDetector === 'undefined') return reject('UNSUPPORTED'); |
This file contains 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
<?php | |
/* | |
Place this file in writable directory. Each incoming request will be saved as a file. | |
Sample file name: | |
callback_POST_08-17-2022 13.42.05.780400.txt | |
*/ | |
$now = DateTime::createFromFormat('U.u', microtime(true)); | |
$file_name = 'callback_' . $_SERVER['REQUEST_METHOD'] . '_' . $now->format("m-d-Y H.i.s.u").'.txt'; |
This file contains 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
- Why subscriptions of apps purchased in App Store can be cancelled only in "Music"? | |
- Why navigating between maximized window and non-maximized windows is so hard? | |
- Why Finder can't be maximized? | |
- Why file paths are hidden? | |
- Why "open file"/"save file" dialog suck so much? | |
- Why transfer speed is hidden when moving file between location A and B ? |
This file contains 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
/* | |
* I had to print a lot of json data on a printer so I wanted to make it | |
* as compact as possible. | |
* | |
* This snippet changes text JSON into compact form. | |
* | |
* input: | |
* `{ | |
* "width": 1080, | |
* "height": 1920, |
This file contains 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
/* | |
* Some JS objects like InputDeviceInfo or GeolocationCoordinates are impossible to clone easly. | |
* `Object.keys(obj)` returns `{}` | |
* `JSON.stringify(obj)` returns `{}` | |
* | |
* with following functions you're able to clone object properties to the simple object. | |
*/ | |
function cloneGeolocationCoordinates(instance) { | |
return Object.keys(instance.constructor.prototype).reduce((acc, key) => { |
This file contains 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
// Extra filters for https://github.com/kig/canvasfilters.git | |
Filters.scaleUp = function (imageData, scale = 2) { | |
const sourceWidth = imageData.width; | |
const sourceHeight = imageData.height; | |
const targetWidth = parseInt(sourceWidth * scale, 10); | |
const targetHeight = parseInt(sourceHeight * scale, 10); |
This file contains 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
/* | |
* This code helps with logging image processed in the worker. | |
* | |
* Simple visual explanation for image transformation. | |
*/ | |
// WORKER: | |
postMessage({ | |
imageData, | |
}); |
This file contains 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 initialNumberOfPairs = 1; | |
let adultPairsNumber = 0; | |
let youngPairsNumber = initialNumberOfPairs; | |
for (let i = 1; i <= 12; ++i) { | |
const prevAdultPairsNumber = adultPairsNumber; | |
adultPairsNumber = adultPairsNumber + youngPairsNumber; | |
youngPairsNumber = prevAdultPairsNumber; |
This file contains 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
/** | |
* Transfer localStorage easly with chrome console. | |
* Paste this into web console of source page, then paste function's result to destination console. | |
**/ | |
(function() { | |
let result = 'localStorage.clear();\n'; | |
Object.keys(localStorage).forEach((key) => { | |
result += `localStorage["${key}"] = ${JSON.stringify(localStorage[key])};\n` | |
}); |