function getCombination(arr, n) {
const sortedArr = JSON.parse(JSON.stringify(arr)).sort();
const results = [];
const part = [];
for(let i = 0; i < sortedArr.length; i++) {
part.push(sortedArr[i]);
const summ = part.reduce((a, b) => a + b);
if (summ === n) {
results.push([...part]);
}
if (summ > n) {
part.pop();
i = sortedArr.indexOf(part[part.length - 1]);
part.pop();
}
}
return results;
}
console.log(getCombination([7, 8, 3, 4, 5, 6, 1, 2], 8));
// [[1, 2, 5], [1, 3, 4], [1, 7], [2, 6], [3, 5], [8]]
const script = document.createElement('script');
script.type = "text/javascript";
script.src="https://code.jquery.com/jquery-3.5.1.min.js";
document.head.appendChild(script);
let time = 0;
const buttons = $("button");
eachButtons();
function eachButtons() {
$.each(buttons , (index, button) => {
const text = $(button).text();
if(text.includes("Кнопка ")) {
clickButton(index, button, time);
time+=1000;
}
});
}
function clickButton(index, button, t) {
setTimeout(function(){
$(button).click();
console.log($(button).text())
if (index === buttons.length - 1) {
time = 1000;
eachButtons();
}
}, t);
}
let socket = new io("http://localhost:7777", { query: "id=123" });
io.on("connection", socket => {
let id = socket.handshake.query.id;
console.log(id) // 123
})
@keyframes star-rotate{
0% {
transform: matrix3d(0.993184, 0.116555, 0, 0, -0.116555, 0.993184, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
}
50% {
transform: matrix3d(0.995187, -0.0979929, 0, 0, 0.0979929, 0.995187, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
}
100% {
transform: matrix3d(0.992688, -0.12071, 0, 0, 0.12071, 0.992688, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
}
}
@keyframes star-rotate-2{
0% {
transform: matrix3d(0.992688, -0.12071, 0, 0, 0.12071, 0.992688, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
}
50% {
transform: matrix3d(0.995187, -0.0979929, 0, 0, 0.0979929, 0.995187, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
}
100% {
transform: matrix3d(0.993184, 0.116555, 0, 0, -0.116555, 0.993184, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
}
}
function validator(value) {
return {
equal(array) {
if(array.toString() === value.toString()) {
return true;
} else {
return false;
}
},
isArray() {
if(Array.isArray(value)) {
return this;
} else {
return false;
}
},
isString() {
if(typeof value === "string") {
return true;
} else {
return false;
}
},
isNumber() {
if(typeof value === "number") {
return true;
} else {
return false;
}
}
}
}
console.log(validator('1').isArray()); // false
console.log(validator([]).isArray().equal([1, 2, 3])); // false
console.log(validator([1, 2, 3]).isArray().equal([1, 2, 3])); // true
console.log(validator('1').isString()); // true
console.log(validator('1').isNumber()); // false
module.exports = { GetFromSQL }
function GetFromSQL (pool, request, callback) {
pool.getConnection(function (err, connection) {
if (err) throw err;
connection.query(request, function (error, results, fields) {
connection.release();
if (error) throw error;
callback(results)
});
});
}
SQL.GetFromSQL(pool, request, function(results) {
// lol kek
})