# --rbind mounts subdirectories that are required.
sudo mount /dev/sda3 /mnt/
sudo mount --rbind /proc/ /mnt/proc/
sudo mount --bind /sys/ /mnt/sys/
sudo mount --rbind /dev/ /mnt/dev/
sudo chroot /mnt/
# Repair grub in /etc/default/grub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const idMapping = data.reduce((acc, el, i) => { | |
acc[el.id] = i; | |
return acc; | |
}, {}); | |
let root = []; | |
data.forEach(el => { | |
// Handle the root element | |
if (el.parent === null) { | |
root.push(el); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// nestedTree is a tree structure containing subtrees under "nodes" property. d=1 is the default "depth of the tree" | |
function flatDeep(arr, d = 1) { | |
return d > 0 ? arr.reduce((acc, val) => acc.concat(Array.isArray(val.nodes) ? flatDeep(val.nodes, d - 1) : val), []) | |
: arr.slice(); | |
}; | |
let flat = flatDeep(nestedTree, Infinity); | |
// Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat |
OlderNewer