Skip to content

Instantly share code, notes, and snippets.

View CezaryDanielNowak's full-sized avatar

Cezary Nowak CezaryDanielNowak

  • Testucan
  • Warsaw, Poland
View GitHub Profile
$$('td[colspan="6"]').forEach((el) => el.parentNode.remove())
// ==UserScript==
// @name JIRA migration alert
// @match https://YOUR_OLD_JIRA_ADDRESS.atlassian.net/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
//+------------------------------------------------------------------+
//| MAX_LOT_ADVISOR.mq5 |
//| Cezary Daniel Nowak |
//| |
//+------------------------------------------------------------------+
#property copyright "Cezary Daniel Nowak"
#property link ""
#property version "1.00"
// NOTES:
/* string-based date-selector, for dates saved in format YYYY-MM-DD or YYYY.MM.DD or YYYYMMDD */
function selectByDateRange(arr, from, to, fieldName = 'date') {
const result = [];
for(let i = 0, max = arr.length; i < max; ++i) {
if (arr[i][fieldName] >= from && arr[i][fieldName] <= to) {
result.push(arr[i]);
}
}
return result;
}
/**
* Simple queue implementation.
* It can replace Promise.all
* No concurrency, just one by one
*/
function withQueue(ConstructorObject) {
return class PromiseWithQueue extends ConstructorObject {
static async queue(arr) {
const result = [];
for (let i = 0; i < arr.length; ++i) {
function chunkString(string, chunkSize) {
// 'abcdefghij' becomes ['abc', 'def', 'ghi', 'j'] when chunkSize is 3.
return string.match(new RegExp(`.{1,${chunkSize}}`, 'g'));
}
/**
* NOTE: This function can and should be written better.
* toHumanReadable shortens sha1 hash (0-9a-f) and presents it with declared set of CHARS.
* @param {String} hash 40-characters sha1 hash
* @param {Number} step chunk size
const HASH = 'f'.repeat(40); // sha1
for (var i = HASH.length; i > 0; --i) {
humanReadableHash = toHumanReadable(HASH, i);
console.log(i, humanReadableHash, humanReadableHash.length);
}
function toHumanReadable(hash, step = 10) {
if (step > 13) {
return 'UNSAFE';
<!DOCTYPE html>
<button type="button" id="getAccessButton">GET LOW ACCURACY LOCATION</button>
<button type="button" id="getHighAccessButton">GET HIGH ACCURACY ACCESS</button>
<h2 id="resultTitle"></h2>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
<pre id="result" style="border: 1px solid #AAA; padding: 10px;"></pre>
<h2>Map</h2>
/**
* This function replaces built-in `confirm` function, but it's async
* Sample usage:
const exitFullscreen = await confirm('Do you really want to exit full-screen mode?');
* @param {String} askText Text to display on the dialog
* @param {Array} buttonText Array with captions of the buttons
* @return {Promise} Resolves with true or false
*/
function confirm(askText = '', buttonText = ['Cancel', 'OK']) {
x = `abort Sent when playback is aborted; for example, if the media is playing and is restarted from the beginning, this event is sent.
canplay Sent when enough data is available that the media can be played, at least for a couple of frames. This corresponds to the HAVE_ENOUGH_DATA readyState.
canplaythrough Sent when the ready state changes to CAN_PLAY_THROUGH, indicating that the entire media can be played without interruption, assuming the download rate remains at least at the current level. It will also be fired when playback is toggled between paused and playing. Note: Manually setting the currentTime will eventually fire a canplaythrough event in firefox. Other browsers might not fire this event.
durationchange The metadata has loaded or changed, indicating a change in duration of the media. This is sent, for example, when the media has loaded enough that the duration is known.
emptied The media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded