function lazyAsync(lib) {
let promise;
return async function (...args) {
promise ??= lib();
return (await promise).call(this, ...args);
};
}
const doSomething = lazyAsync(async () => {
// тут загружаем
const doSomething = await loadLib('doSomething');
// тут что-то делаем с загруженным
// тут возвращаем конечную функцию
return data => {
// тут делаем с аргументами
return doSomething.process(imgData);
};
});
// если сразу загружается нужная функция - можно не усложнять
const doSomething = lazyAsync(loadDoSomethingProcess);
await doSomething(1);
await doSomething(2);
await doSomething(3);
const links = {
36624938042: 'https://marketing-parsing3.tilda.ws/im/tproduct/368371303452-radialnie-opravki-levie-korotkie-vdi-b3',
48534127142: 'https://marketing-parsing3.tilda.ws/im/tproduct/579863714382-blok-privodnoi-radialnii-vdi40-5480-er32'
}
const searchParams = new URLSearchParams(location.search)
const utm = searchParams.get('utm_term')
if(utm && links.hasOwnProperty(utm)) {
location.href = links[utm]
}
<input placeholder="Ваш email" type="email" class="email_text" name="Re_Enter_Email" id="Re_Enter_Email" value="" required="required" onblur="preSubmitPay(0);" onkeydown="$('#err_email_enter_msg').hide();" oncopy="return false" ondrag="return false" ondrop="return false" onpaste="return false" autocomplete="off">
document.getElementById('Re_Enter_Email').value = "email@email.tld";
value
, чем морочиться с отключением событий on*
и имитировать пользовательский ввод. Saying that Ctrl-D sends EOF is an educational lie-to-children. What it actually does is make any ongoing read() from the terminal return immediately with the contents of the current line buffer if any.
Synergy happens because the Unix convention is that a read() of zero bytes represents EOF.
This means that if you press Ctrl-D with an empty buffer, the read() will return with zero bytes, and a canonical program will interpret it as end-of-file. This is obviously just an illusion since you're still there to input more on the terminal, and a less canonical program could just keep reading if it wanted to.
If you instead press Ctrl-D after entering some data, then that data is just returned and a canonical program will keep reading to find a linefeed or whatever else it's looking for.
This is why EOF behavior is only triggered in canonical programs when Ctrl-D is pressed either after another Ctrl-D (the first flushes the buffer, the second returns a now-empty buffer) or after an Enter (for the same reason).
DELETE FROM table2
WHERE NOT EXISTS (SELECT id FROM table1 WHERE table2.id = table1.id);
Ведь мы создаем новый li при клике на btn, и он попадает в DOMНу да, попадает. А чтобы что-то с ним делать, нужно навесить обработчик события. Совершенно непонятно, что вас в этом процессе удивляет.
<ol />
) и тогда навешивать отдельные обработчики на создаваемые элементы не придётся. - var_dump( $str );
+ echo bin2hex($str);
Получаем cf f0 e8 e2 e5 f2 20 32 30 31 39 20 cc e8 f0 21
Привет 2019 Мир!
$str = 'Привет 2019 Мир!'; // написано в той кодировке, в которой сохранен файл (хрустальный шар говорит, что utf-8)
$str = mb_convert_encoding( $str, 'windows-1251', mb_detect_encoding( $str ) ); // конвертируем в cp1251
header('Content-Type: text/html; charset=windows-1251'); // Откуда трабла с кодировкой? - не соответствие сообщаемой кодировки в http-заголовке от сервера, с выводимым контентом от сервера. Исправляется явным указанием заголовка
var_dump( $str ); // выводим в той кодировке, что выводит заголовок charset сервера в браузер (хрустальный шар говорит, что до указания header() было charset=utf-8)