const { exec } = require('child_process');
exec('python test.py', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
count = 0
while count < 1e6:
count = count + 1
print(count)
const req = {array: '[{num: 1}, {num: 2}, {num: 3}]'};
const array = eval(req.array);
console.log(array);
<!doctype html>
<html>
<head>
</head>
<body>
</body>
<script>
document.addEventListener("click", (event) => {
if (event.target.className === 'img') {
alert('click on img');
}
});
const showJoke = (id, category, joke, updated) => {
return `
<div class="joke">
<div class="joke__id">
id: <a href="https://api.chucknorris.io/jokes/${id}">ID: ${id}</a><img src="../link.png" alt="">
</div>
// на эту картинку нужно повесить событие
<img class="img" src="https://img.icons8.com/ios/50/000000/like.png">
//
<div class="joke__text">
${joke}
</div>
<div class="joke__info">
<div class="info__updated">
Last update: ${updated} hours ago
</div>
<div class="info__category">
${category}
</div>
</div>
</div>
`;
};
const html = showJoke('id', 'category', 'joke', 'updated');
document.body.insertAdjacentHTML('afterbegin', html);
</script>
</html>
console.log(Number.MAX_SAFE_INTEGER)
//9007199254740991
const array = [9, 2, 2, 3, 3, 7, 2, 0, 3, 6, 8, 5, 4, 7, 7, 5 , 6,7,7];
const number = BigInt(array.join(''));
console.log(number.toString());
const { Builder, By, Key, until } = require('selenium-webdriver');
(async function example() {
let driver = await new Builder().forBrowser('firefox').usingServer('http://localhost:4444/wd/hub').build();
try {
await driver.get('http://www.google.com/ncr');
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
} finally {
await driver.quit();
}
})();
const fetch = require('node-fetch');
fetch('https://httpbin.org/delete', {
method: 'DELETE',
headers: {
"teacherId": 8
}
})
.then(res => res.text())
.then(text => {
console.log(text);
});
/usr/local/bin/node /Users/evgenij/projects/fetch.js
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "gzip,deflate",
"Host": "httpbin.org",
"Teacherid": "8",
"User-Agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)",
"X-Amzn-Trace-Id": "Root=1-5e99af90-fe7e43f7f3d1149a814fd762"
},
"json": null,
"origin": "*******",
"url": "https://httpbin.org/delete"
}
const axios = require('axios');
const qs = require('qs');
const token = '***************';
const url = `https://api.vk.com/method/users.get?access_token=${token}&v=5.103`;
const ids = Array.from({ length: 1000 }, (v, k) => k + 1);
const post = { 'user_ids': ids.join(',') };
(async () => {
const response = await axios({
method: 'post',
url: url,
data: qs.stringify(post),
headers: { 'content-type': 'application/x-www-form-urlencoded' }
});
console.log(response.data);
})();
<html>
<body>
<div class="wrap">
<ul>
<li>task1</li>
<li>task2</li>
<li>task3</li>
<li>task4</li>
<li>task5</li>
<li>task6</li>
</ul>
<a href="#">more</a>
</div>
<script>
let start = 0;
let limit = 2;
function render(elements, start, limit) {
elements.forEach((el, index) => {
el.style.display = (index < start + limit) ? 'block' : 'none';
});
}
const elements = document.querySelectorAll('ul > li');
document.querySelectorAll('a')[0].onclick = () => {
start += limit;
render(elements, start, limit);
};
render(elements, start, limit);
</script>
</body>
</html>