pip3 install --user pyqt5
sudo apt-get install python3-pyqt5
sudo apt-get install pyqt5-dev-tools
sudo apt-get install qttools5-dev-tools
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
/** "Lorem ipsum" style text. */ | |
/** | |
* Produces a random number | |
* @return {Number} Random number | |
*/ | |
export function gauss() | |
{ | |
return (Math.random() * 2 - 1) + (Math.random() * 2 - 1) + (Math.random() * 2 - 1) | |
} |
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 noop = () => {} | |
export class Cancelable extends Promise | |
{ | |
constructor(executor = noop) | |
{ | |
super((resolve, reject) => { | |
executor(v => { | |
/** |
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
/** | |
* @see https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/queueMicrotask | |
*/ | |
export const queueMicrotask = (function() { | |
const queueMicrotask = typeof window !== 'undefined' | |
? window.queueMicrotask | |
: undefined | |
return queueMicrotask || (cb => { | |
Promise.resolve().then(cb).catch(e => setTimeout(() => { throw e })) |
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
Object.defineProperty(Array.prototype, 'binarySearch', { | |
value(target, comparator) { | |
let l = 0, | |
h = this.length - 1, | |
m, comparison | |
/* default comparison method if one was not provided */ | |
comparator = comparator || function(a, b) { | |
return (a < b ? -1 : (a > b ? 1 : 0)) | |
} |
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
export class AsyncArray extends Array | |
{ | |
[Symbol.asyncIterator]() | |
{ | |
let i = 0 | |
return { | |
next: () => new Promise(resolve => { | |
setTimeout(() => resolve({ value: this[i], done: i++ === this.length })) | |
}) |
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
export function str2ab(str) | |
{ | |
let buf = new ArrayBuffer(str.length * 2) // 2 bytes for each char | |
let bufView = new Uint16Array(buf) | |
for (let i = 0, strLen = str.length; i < strLen; i++) { | |
bufView[i] = str.charCodeAt(i) | |
} | |
return buf |
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
export function ab2str(buf) | |
{ | |
return String.fromCharCode.apply(null, new Uint16Array(buf)) | |
} |
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 convertToWebp(string $src, int $quality = 100): string | |
{ | |
$dir = pathinfo($src, PATHINFO_DIRNAME); | |
$name = pathinfo($src, PATHINFO_FILENAME); | |
$ext = pathinfo($src, PATHINFO_EXTENSION); | |
$dest = "$dir/{$name}_$ext.webp"; | |
$is_alpha = false; | |
switch (mime_content_type($src)) { |
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
// Immutable Shuffle | |
const shuffleImmutable = (arr) => arr.slice().sort(() => Math.random() - 0.5) | |
// Random number in range | |
const randomInRange = (from, to) => Math.floor(from + Math.random() * (to - from + 1)) | |
// Array with unique items | |
const uniqueItems = (arr) => [...new Set(arr)] | |
// Uppercase firs letter |