docker network connect myapp_default mysql
mysql
, как и требовалось. while()
и не for()
— может, прокатит?// случайные:
const myArray = [...Array(3)]
.map(
row =>
[...Array(3)]
.map(
el => Math.floor(Math.random() * 10)
)
)
;
// диагональ, где оба индекса равны:
const diagonal = myArray
.map(
(row, rowIndex) =>
row
.map(
(el, elIndex) => rowIndex === elIndex ? 1 : 0
)
)
;
/**
* асинхрота с запросом. Возвращает Promise
*/
const doAsyncStuff = (urlIter, urlSite) => new Promise((resolve, reject) => {
needle.get(urlIter, (err, result) => { // Сама асинхронная функция
if (err) reject(err);
$('.product-card__link')
.each((i, val) => prodLink.push(urlSite + $(val).attr("href")));
resolve();
})
})
/**
* Тот самый цикл
* @param {number} quanPage число страниц
*/
const doStuff = async quanPage => {
for(let i = 1; i <= quanPage; i++) {
let urlIter = urlSite + i; // Ссылка, которая создается с каждой новой итерацией
await doAsyncStuff(urlIter, urlSite); // Ждём-с!
}
}
doStuff(10);
if(check){
if(true || check) { // временно убрали проверку заполнения всех полей. TODO убрать костыль
function sub(form_id){
$("#img_loader").val($("#files").find("img").attr("src"));
$.ajax({
type: 'POST',
url: '/php.php',
data: $('#'+form_id).serialize(),
success: function(data) {
$("#recall_wrapper").html("<p class='title_recall'>Ваш отзыв успешно отправлен</p>");
setTimeout(() => window.location.href='/recalls_ok.htm', 1000); // перекидывать не сразу, а через 1 сек
},
error: function(xhr, str){
$("#status__send").text('Возникла ошибка: ' + xhr.responseCode);
}
});
}
FooSearchComponent
, в который через props из родителя передаём реактивное свойство foo
:Vue.component(
"FooSearchComponent",
{
props: ['foo'],
template: '<div>
<a
href="#"
@click="searchFoo(foo)"
>
{{ foo }}
</a>
</div>',
methods: {
searchFoo: function(search) {
console.log("searchFoo:", search);
},
}
}
);
searchFoo()
в который параметром передаётся свойство (реактивное, извне) foo
f(1, 1) = 100
f(1, 95) = 1.05
f = ?
x - x1 y - y1
------- = -------
x2 - x1 y2 - y1
98.95 * x + 94 * y = 9498.95
// ...
$('input').each(function (index) {
$(this).val(decode[index]);
});
0, 1, 2, ...
И если разметка документа не менялась, можно надеяться, что порядок найдённых input'ов будет тот же, что и при сохранении значений. Способ не гарантирует попадание значения в нужный input, но в простом случае упражнения сработает.id
и сохранять их вместе со значениями. При восстановлении обращаться к элементам по id
. lodash
пишут в документации Sails:Async (async
) and Lodash (_
)
Sails also exposes an instance of lodash as_
, and an instance of async asasync
. These commonly-used utilities are provided by default so that you don't have to npm install them in every new project. Like any of the other globals in sails, they can be disabled.
globals.js
предназначен только для отключения некоторых глобалов-по-умолчанию:// config/globals.js
module.exports.globals = {
_: false,
async: false,
models: false,
services: false
};
_: require('lodash')
воспринимается, видимо, так же, как и _: true
– т.е. просто не-запрещает эту глобальную переменную.let one = ['one', 'two', 'three', 'four', 'five'];
let two = ['a', 'b', 'five', 'c', 'one'];
const [long, short] = one.length > two.length ? [one,two] : [two,one];
short.sort();
const shortLength = short.length;
const binSearch = needle => {
let start = 0, finish = shortLength - 1;
while (start <= finish) {
const center = Math.floor((start + finish) / 2);
if (short[center] < needle) start = center + 1;
else if (short[center] > needle) finish = center - 1;
else return true;
}
return false;
}
const result = [];
for (let i = 0, length = long.length; i < length; i++)
if (binSearch(long[i])) result.push(long[i]);
result // ["five","one"]
ffmpeg -i left.avi -i right.avi -filter_complex "
nullsrc=size=200x100 [background];
[0:v] setpts=PTS-STARTPTS, scale=100x100 [left];
[1:v] setpts=PTS-STARTPTS, scale=100x100 [right];
[background][left] overlay=shortest=1 [background+left];
[background+left][right] overlay=shortest=1:x=100 [left+right]
" output.mp4
ffmpeg \
-i fon.jpg \
-i vertvideo.mp4 \
-filter_complex " \
[0:v] setpts=PTS-STARTPTS, scale=1280x720 [fon]; \
[1:v] setpts=PTS-STARTPTS, scale=-2x720 [video]; \
[fon][video] overlay=x=(W-w)/2 \
" \
-y -hide_banner \
result.mp4