if(gte(t,9)*lte(t,29)
if(gte(t,20)*lte(t,25)
ffmpeg \
-y \
-i "$file" \
-vcodec libx264 \
-movflags +faststart \
-threads 0 \
-r 25 \
-g 50 \
-crf 25 \
-me_method hex \
-trellis 0 \
-bf 8 \
-acodec aac \
-strict \
-2 \
-ar 44100 \
-ab 128k \
-f mp4 \
-vf "movie=watermark.png [wm];[in][wm] overlay='if(gte(t,9)*lte(t,29), W-((W+w)/20)*mod(t-9,20), -w-1000)':'0' [out]" \
"out/$file"
const img = document.querySelector("img");
const canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
const ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
canvas.toBlob((blob) => {
blob.arrayBuffer()
.then((buf) => {
// тут как-то отправить эту буффонаду через WebSocket
})
.catch(console.error)
;
}, "image/png");
var array = [
{
'key1': 'value1'
},
{
'key2': 'value2'
},
{'key1': 'value1-b'},
{'key1': 'value1-c'},
]
Массив объектов, в каждом из которых всего по 1 свойству. str
, и на выходе, видимо, массив значений. const getValues = (array, key) => array.filter((item) => item.hasOwnProperty(key))
.map((item) => item[key]);
getValues(array, "key1") // [ "value1", "value1-b", "value1-c" ]
const startDate = new Date(2021, 7, 8); // начало отсчёта
const today = new Date(); // сегодня
const daysPassed = Math.floor((today - startDate) / 864e5);
const future = new Date();
future.setDate(future.getDate() + 3 - daysPassed % 3);
document.querySelector('span.myDate')
.textContent = new Intl.DateTimeFormat(
'ru-RU',
{ month: 'long', day: 'numeric' }
)
.format(future);
:value="xxx"
selected
— точно так же0
потому, что первая буква имеет индекс 0
.s.length
– т.к. у последней буквы строки индекс s.length - 1
i++
или i = i + 1
— по одной позиции направо продвигаемся. ctx.clearRect(0 , 0 , ctx.canvas.width , ctx.canvas.height)
https://site.ru/download/1202
и веб сервер отдаст на этот запрос файл с того секретного сайта с id 1202
. $mysql = new mysqli("localhost", "root", "root", "medixer");
$mysql->set_charset("utf8");
$stmt = $conn->prepare("INSERT INTO `users` (`login_user`, `name`, `password`, `dob`, `region`, `telephone`, `email`) VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("sssssss", $login, $name, $password, $dob, $region, $telephone, $email);
$stmt->execute();
$mysql->close();
function spread(q, volumes) {
const total = volumes.reduce((a, b) => a + b);
const result = volumes.slice().fill(0);
const target = volumes.map((v) => q * v / total);
while (q--) {
const demand = result.map((v, i) => target[i] - v);
const minIndex = demand.indexOf(Math.max(...demand));
result[minIndex]++;
}
return result;
}
spread(4, [1, 10, 3]) // [0, 3, 1]
spread(9, [1, 10, 3]) // [1, 6, 2]
spread(1, [10, 10, 10]) // [1, 0, 0] - слева направо при равных
spread(33, [10, 10, 10]) // [11, 11, 11] - переполняются тоже одинаково
spread(4, [2, 3, 1]) // [ 1, 2, 1 ]
spread(5, [2, 3, 1]) // [ 2, 2, 1 ]
spread(9, [2, 3, 1]) // [ 3, 5, 1 ]
index2 - index1 + 1
и заменить его фразой replacement.