Basic:
var Device = function(opt) {
this.id = opt.id;
this.type = opt.type;
};
Device.prototype.getId = function() {
return this.id;
};
Device.prototype.getType = function() {
return this.type;
}
var Relay = function(opt) {
// call the inherited constructor
Device.call(this, opt);
this.code = opt.code;
};
Relay.prototype.getCode = function() {
return this.code;
};
// Relay will inherit Device
Relay.prototype = Object.create(Device.prototype);
var device = new Relay({id: 123, type: 'test', code:'RL-01'});
console.log(device);
console.log(device instanceof Device); // true
console.log(device instanceof Relay); // true
With some more structure:
var Device = (function() {
function F(opt) {
this.id = opt.id;
this.type = opt.type;
}
F.prototype.getId = function() {
return this.id;
};
F.prototype.getType = function() {
return this.type;
}
return F;
}());
var Relay = (function() {
function F(opt) {
// call the inherited constructor
Device.call(this, opt);
this.code = opt.code;
}
F.prototype.getCode = function() {
return this.code;
}
// Relay will inherit Device
F.prototype = Object.create(Device.prototype);
return F;
}());
var device = new Relay({id: 123, type: 'test', code:'RL-01'});
console.log(device);
console.log(device instanceof Device); // true
console.log(device instanceof Relay); // true
function ajaxGet(url, cb){
var req = new XMLHttpRequest();
req.onload = function() {
cb(req.status, req.response);
};
req.open("GET", url);
req.send();
}
ajaxGet('https://httpbin.org/get', function(status, res) {
console.log(status , JSON.parse(res));
})
find is the common tool for this kind of task:
find ./my_dir -mtime +10 -type f -delete
EXPLANATIONS
./my_dir your directory (replace with your own)-mtime +10 older than 10 days-type f only files-delete no surprise. Remove it to test your find filter before executing the whole command!And take care that ./my_dir exists to avoid bad surprises!
To achieve this, ssl module has to be enabled and apache needs to be told, how to handle traffic from port 443, this is done by enabling default-ssl site.
$ sudo a2enmod ssl
$ sudo a2ensite default-ssl
$ sudo service apache2 restart
Firewall
If you have firewall enabled, you should allow incoming TCP connection on port 443.
$ sudo ufw allow 443/tcp