function isJson(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
One of the best things about being a MATE user is the fact that everything is super stable and reliable. This desktop environment hasn’t changed its looks in quite a long time. Everything is nearly like the way it looked in 2002.
This can be a good thing when it comes to usability. It’s tried and true. On the other hand, the MATE desktop doesn’t look very modern. The default themes it ships with aren’t very attractive, and overall it seems like it needs a face-lift.
Check out these nine themes that look great in the MATE desktop environment!
Two very nice, tested and working themes + icon set.
Ambiance & Radiance Flat
Vibrancy Colors Icon
To find the tool to reconfigure the audio ports is this easy under Ubuntu 14.04.1 LTS.
sudo apt-get install alsa-tools-gui
hdajackretask
Usage:
ps_mem [-h|--help] [-p PID,...] [-s|--split-args] [-t|--total] [-w N]
Example output:
Private + Shared = RAM used Program
34.6 MiB + 1.0 MiB = 35.7 MiB gnome-terminal
139.8 MiB + 2.3 MiB = 142.1 MiB firefox
291.8 MiB + 2.5 MiB = 294.3 MiB gnome-shell
272.2 MiB + 43.9 MiB = 316.1 MiB chrome (12)
913.9 MiB + 3.2 MiB = 917.1 MiB thunderbird
---------------------------------
1.9 GiB
=================================
Recursive functions can be very effective in manipulating tree structures such as the browser’s Document Object Model (DOM). Each recursive call is given a smaller piece of the tree to work on.
// Javascript - The Good Parts page: 35
var walkTheDom, getElementsByAttribute;
Define a walkTheDom
function that visits every node of the tree in HTML source order, starting from some given node. It invokes a function, passing it each node in turn. walkTheDom
calls itself to process each of the child nodes.
walkTheDom = function walk(node, funk) {
funk(node);
node = node.firstChild;
while(node) {
walk(node, funk);
node = node.nextSibling;
}
};
Define a getElementsByAttribute
function. It takes an attribute name string and an optional matching value. It calls walkTheDom
, passing it a function that looks for an attribute name in the node. The matching nodes are accumulated in a results array.
getElementsByAttribute = function(att, value) {
var results = [];
walkTheDom(document.body, function(node) {
var actual = node.nodeType === 1 && node.getAttribute(att);
if (typeof actual === 'string' &&
(actual === value || typeof value !== 'string')) {
results.push(node);
}
});
return results;
};