// Create a new object, that prototypally inherits from the Error constructor
function MyError(message) {
this.name = 'MyError';
this.message = message || 'Default Message';
this.stack = (new Error()).stack;
}
MyError.prototype = Object.create(Error.prototype);
MyError.prototype.constructor = MyError;
try {
throw new MyError();
} catch (e) {
console.log(e.name); // 'MyError'
console.log(e.message); // 'Default Message'
}
try {
throw new MyError('custom message');
} catch (e) {
console.log(e.name); // 'MyError'
console.log(e.message); // 'custom message'
}
... checks:
isJson(str)
isStr(str)
isArr(arr)
isObj(obj)
isNum(num)
isUndefined()
isFnx(fx)
isSet(variable)
... converters:
toBool(data)
... seekers:
inArr(needle, arrhaystack)
inStr(str, char)
getKey(obj, value)
setCharAt(str, index, char)
// ...checks
function isJson(str) {
try {
return JSON.parse(str);
} catch (e) {
return false;
}
}
function isStr(str) {
try {
return str.constructor === String;
} catch (e) {
return false;
}
}
function isArr(arr) {
try {
return arr.constructor === Array;
} catch (e) {
return false;
}
}
function isObj(obj) {
try {
return obj.constructor === Object;
} catch (e) {
return false;
}
}
function isNum(num) {
return !isNaN(num);
}
function isUndefined(data) {
return typeof data === "undefined";
}
function isFnx(fx) {
return typeof fx === 'function';
}
function isSet() {
var a = arguments,
l = a.length,
i = 0,
undef;
if (l === 0) {
throw new Error('Empty isset');
}
while (i !== l) {
if (a[i] === undef || a[i] === null) {
return false;
}
i++;
}
return true;
}
// ...converters
function toBool(data) {
return !!data;
}
/// ...seekers
function inArr(needle, arrhaystack) {
return (arrhaystack.indexOf(needle) > -1);
}
function inStr(str, char) {
if (typeof str === 'string') {
return str.indexOf(char) !== -1;
}
return false;
}
function getKey(obj, value){
for(var key in obj) {
if(obj[key] == value){
return key;
}
}
return null;
}
function setCharAt(str, index, char) {
return str.substr(0, index) + char + str.substr(index + char.length);
};
Universal operating system installer.
For people short on SD cards: Berryboot is a simple boot selection screen, allowing you to put multiple Linux distribution on a single SD card.
In addition it allows you to put the operating system files on an external USB hard drive instead of on the SD card itself.
Scan
iwlist wlan0 scan
Connect
iwconfig wlan0 essid "<ssid>" key "<pass>"
read -p "confirm [y/N]: " -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi