- Create the group Use groupadd. You’ll likely need sudo for this.
sudo groupadd my-new-group- Add yourself to the group If you want to be able to work with these files without using sudo every time, add your user to the group:
| // modern_string.cpp | |
| #include <algorithm> | |
| #include <cassert> | |
| #include <cstddef> | |
| #include <cstring> | |
| #include <initializer_list> | |
| #include <iostream> | |
| #include <iterator> | |
| #include <stdexcept> | |
| #include <string> |
# --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| // 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 |
| 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); |
| #!/bin/bash | |
| sudo /usr/local/bin/certbot-auto renew | |
| sudo cp /etc/letsencrypt/live/domain.com/* /etc/lighttpd/certs/ | |
| cd /etc/lighttpd/certs | |
| sudo cat privkey.pem cert.pem | sudo tee merged.pem | |
| sudo systemctl restart lighttpd.service | |
| ## Renew every two months |
| #!/bin/bash | |
| # delete previous version if needed | |
| INSTALL_DIR=/usr/share/code | |
| if [ -d "$INSTALL_DIR" ]; then | |
| echo "deleting: $INSTALL_DIR" | |
| sudo rm -rf $INSTALL_DIR | |
| fi | |
| # download the rpm from https://code.visualstudio.com/download |
On the computer without public IP:
ssh -R 2222:localhost:22 loginOfServerWithPublicIP@publicIP
This connects to the server by SSH and builds a tunnel from the server with public IP on port 2222 to the computer without public IP on port 22 (SSH).
And then on the server:
ssh -p 2222 loginOfComputerWithoutPublicIP@locahost
| function long { | |
| START=$(date +%s.%N) | |
| $* | |
| EXIT_CODE=$? | |
| END=$(date +%s.%N) | |
| DIFF=$(echo "$END - $START" | bc) | |
| RES=$(python -c "diff = $DIFF; min = int(diff / 60); print('%s min' % min)") | |
| result="$1 completed in $RES, exit code $EXIT_CODE." | |
| echo -e "\n⏰ $result" | |
| ( say -r 250 $result 2>&1 > /dev/null & ) |
| #include <stdio.h> | |
| typedef void (*functionType)(); | |
| void doThis() { | |
| printf("Hello World!\n"); | |
| } | |
| int main() { | |
| functionType doVar = &doThis; |