grep -q
всегда пустая строка, [ -n '' ]
всегда будет falseif cat /etc/passwd | cut -d: -f1 | grep -q "$CUSTOM_USER"; then
if id $CUSTOM_USER &>/dev/null; then
$ sctl() { sudo systemctl "$@"; systemctl status "${@:2}" --lines 0 --no-pager 2>/dev/null; }
$ sctl restart mongodb
● mongodb.service - High-performance, schema-free document-oriented database
Loaded: loaded (/usr/lib/systemd/system/mongodb.service; disabled; vendor preset: disabled)
Active: active (running) since Пт 2016-06-10 10:32:56 MSK; 13ms ago
Main PID: 10048 (mongod)
Tasks: 1 (limit: 512)
CGroup: /system.slice/mongodb.service
└─10048 /usr/bin/mongod --quiet --config /etc/mongodb.conf
convertToNumber($(a).find('#price').html()) < convertToNumber($(b).find('#price').html()))
//emitter.js
const {EventEmitter} = require('events');
module.exports = new EventEmitter();
//module.js
const e = require('./emitter.js');
e.on('test', n => console.log(n));
//main.js
const e = require('./emitter.js');
require('./module.js');
setInterval(() => { e.emit('test', Math.round(Math.random() * 10)) }, 1000);
<button disabled={this.state.checkrule}>
const resetable = Component => class extends React.Component {
state = {key: 0};
render() {
return <Component
{...this.props}
reset={() => this.setState({key: this.state.key + 1})}
key={this.state.key}
/>;
}
}
примерconst resetable = Component => class extends React.Component {
render() {
return <Component
{...this.props}
reset={() => this.forceUpdate()}
key={Math.random()}
/>;
}
}
items.filter(item => item.groupId === selectedGroup && !selected.some(e => e.id === item.id))
Request URL: https://littleguga.github.io/excuse-generator
Request Method: GET
Status Code: 301 Moved Permanently
Location: http://littleguga.github.io/excuse-generator/
var p72 = {count: 72};
var p84 = {count: 84};
var p90 = {count: 90};
var items = [p72, p84, p90];
var count = 1043;
var minVal = Infinity;
var solutions = [];
var val;
for (var i = 0, item = items[i]; i < items.length; item = items[++i]) item.max = Math.ceil(count / item.count);
for (p72.i = 0; p72.i <= p72.max; p72.i += 1)
for (p84.i = 0; p84.i <= p84.max; p84.i += 1)
for (p90.i = 0; p90.i <= p90.max; p90.i += 1) {
val = p90.i * p90.count + p84.i * p84.count + p72.i * p72.count;
if (val < count) continue;
if (val < minVal) {
solutions = [];
solutions.count = val;
minVal = val;
}
if (val === minVal) solutions.push([p72.i, p84.i, p90.i]);
}
console.log(solutions); // 1044 9 вариатнов