// Dependencies
const express = require('express');
const bodyParser = require('body-parser')
const hbs = require('express-hbs');
const { check, validationResult } = require('express-validator/check');
// Main Appliction
const app = express();
// Begin Body Parser Settings
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
// end Body Parser Settings
// begin Set Engine
app.engine('hbs', hbs.express4({
partialsDir: __dirname + '/'
}));
app.set('view engine', 'hbs');
app.set('views', __dirname + '/');
// end Set Engine
// Main route
app.get('/', (req, res) => res.render('index'))
// Login route
app.post('/user', [
// Form Validation
check('username').isEmail(),
check('password').isLength({ min: 5 })
], (req, res) => {
// Const with errors
const errors = validationResult(req);
// Show Errors in console
console.log(errors.array());
// Check for error
if (!errors.isEmpty()) {
// Render template with errors
return res.render('index', {
errors: errors.array()
})
} else {
// Render template without errors
return res.render('index', {
success: 'Success'
})
}
})
// Listener
app.listen(3000, () => console.log('Example app listening on port 3000!'))
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
{{# if errors }}
{{# each errors }}
<p>{{ this.msg }}</p>
{{/each}}
{{/if}}
{{# if success }}
<p>{{ success }}</p>
{{/if}}
<form method="POST" action="/user">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit" value="Submit">
</form>
</body>
</html>
#!/bin/bash
cp -r /folder/with/files/*.jpeg /destination/folder
.... the rest of the code ...
$ chmod +x myOneButtonApplication.sh
$ ./myOneButtonApplication.sh
The pointer-events CSS property specifies under what circumstances (if any) a particular graphic element can become the target of mouse events.
div::after{
border-radius: 100% 0 0 0;
}
var menu_obj = {
'title': "Save Image in Folder...",
'contexts': ["image"],
'onclick': (function() { return false; })
};
var parent_id = chrome.contextMenus.create(menu_obj);
var folders = JSON.parse(localStorage.getItem("folders"));
var items = {};
for (var i = 0; i < Object.keys(folders).length; i++) {
var child_obj = {
'title': folders[i],
'contexts': ["all"],
'onclick': (function(info,tab) {
var url = info['srcUrl'];
var dir = items[info['menuItemId']];
var filename = dir+url.substring(url.lastIndexOf('/')+1);
chrome.downloads.download({url:url,filename:filename,saveAs: false},function() {
console.log(chrome.runtime.lastError);
});
}),
'parentId': parent_id
};
var id = chrome.contextMenus.create(child_obj);
items[id] = folders[i];
}
Examples
You can find simple examples of using the chrome.downloads API in the examples/api/downloads directory. For other examples and for help in viewing the source code, see Samples.
let array = [1, 2, 3, 4, 5 .... n]
console.log(array[0]) // вывод в консоле 1
console.log(array[1]) // вывод в консоле 2
console.log(array[2]) // вывод в консоле 3
<ul>
<li></li> <!-- li[0] -->
<li></li> <!-- li[1] -->
<li></li> <!-- li[2] -->
<li></li> <!-- li[3] -->
<li></li> <!-- li[4] -->
</ul>
# запретить всё, что не разрешено для входящих
iptables -P INPUT DROP
# разрешить подключаться с IP-адреса 1.2.3.4 по протоколу TCP на порт 20
iptables -A INPUT -s 1.2.3.4 -p tcp --dport 20 -j ACCEPT
# разрешить подключаться с IP-адреса 1.2.3.4 по протоколу TCP на порт 80
iptables -A INPUT -s 1.2.3.4 -p tcp --dport 80 -j ACCEPT
# посмотреть таблицу установленных правил
iptables -nL
<nav>
<a>
<a>
<a>
</nav>
Метод filter() создаёт новый массив со всеми элементами, прошедшими проверку, задаваемую в передаваемой функции.
if (!Array.prototype.filter)
Array.prototype.filter = function(func, thisArg) {
'use strict';
if ( ! ((typeof func === 'Function' || typeof func === 'function') && this) )
throw new TypeError();
var len = this.length >>> 0,
res = new Array(len), // preallocate array
t = this, c = 0, i = -1;
if (thisArg === undefined)
while (++i !== len)
// checks to see if the key was set
if (i in this)
if (func(t[i], i, t))
res[c++] = t[i];
else
while (++i !== len)
// checks to see if the key was set
if (i in this)
if (func.call(thisArg, t[i], i, t))
res[c++] = t[i];
res.length = c; // shrink down array to proper size
return res;
};
<label for="foo">
<select name="foo" id="foo" data-role="none">
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>
#custom-collapsible {
width: 74% !important;
margin-left: 9px !important;
border-width: 0px !important;
background-color: white !important;
}
#custom-collapsible h3 a {
border-width: 0px !important;
background: white !important;
}
var path = s.path(firstPath).attr({"fill-opacity": 0, stroke: "#000"});