diff --git a/scripts/auto_save.sh b/scripts/auto_save.sh index 240f778..b923605 100755 --- a/scripts/auto_save.sh +++ b/scripts/auto_save.sh @@ -2,10 +2,13 @@ # Automatically commits/pull changes to the remote ZK repository. -tidy_filenames="${EOLAS_DIR}/scripts/tidy_filenames.sh" -purge_images="${EOLAS_DIR}/scripts/purge_images.sh" -cd $EOLAS_DIR +zk=$HOME/repos/eolas + +tidy_filenames="${zk}/scripts/tidy_filenames.sh" +purge_images="${zk}/scripts/purge_images.sh" + +cd $zk echo "Standardising file-names..." source ${tidy_filenames} diff --git a/scripts/new_zk_note.sh b/scripts/new_zk_note.sh index 98208fd..d6199d9 100755 --- a/scripts/new_zk_note.sh +++ b/scripts/new_zk_note.sh @@ -1 +1 @@ -zk new --title "$1" +zk new --title "$1" /home/thomas/repos/eolas/zk diff --git a/zk/format_specifiers_in_c.md b/zk/format_specifiers_in_c.md new file mode 100644 index 0000000..2d74f65 --- /dev/null +++ b/zk/format_specifiers_in_c.md @@ -0,0 +1,21 @@ +--- +id: 5faz2y2e +title: Format specifiers in C +tags: [] +created: Thursday, February 29, 2024 | 17:41 +--- + +# Format specifiers in C + +Format specifiers define the type of data to be printed on standard output. You +need to use format specifiers whenever you are +[printing-values-in-c](printing-values-in-c.md). + +| Specifier | Usage | +| --------- | -------------------------- | +| `%c` | single character | +| `%s` | string | +| `%n` | nothing | +| `%d` | integer (assuming base 10) | +| `%f` | float | +| `%%` | The percent sign itself | diff --git a/zk/printing_values_in_c.md b/zk/printing_values_in_c.md new file mode 100644 index 0000000..0ad1da5 --- /dev/null +++ b/zk/printing_values_in_c.md @@ -0,0 +1,25 @@ +--- +id: 3hcv0amc +title: Printing values in C +tags: [] +created: Thursday, February 29, 2024 | 17:33 +--- + +# Printing values in C + +## To print a literal + +```c +printf("hello world") +``` + +## To print a variable + +```c +int age = 25 +print("%d", age) + +``` + +The `%d` is an example of a [format specifier](./zk/format-specifiers-in-c.md). +It is the decimal integer format specifier. diff --git a/zk/systemd.md b/zk/systemd.md index 3c0167d..9f28fb3 100644 --- a/zk/systemd.md +++ b/zk/systemd.md @@ -49,7 +49,7 @@ are as follows: - control service daemons - socket units (`.socket`) - handle incoming network connection request locations -- device units (`.device) +- device units (`.device`) - disks and other devices - mount units (`.mount`) - handle the attachment of filesystems to the system diff --git a/zk/systemd_status.md b/zk/systemd_status.md new file mode 100644 index 0000000..6351cdd --- /dev/null +++ b/zk/systemd_status.md @@ -0,0 +1,48 @@ +--- +id: v5f6xkdv +title: systemd status +tags: [systemd, systems-programming] +created: Thursday, February 29, 2024 | 18:19 +--- + +# Get status of a specific unit + +Here I have requested the status of the currently running `mongodb` unit: + +``` +$ systemctl status mongod +mongodb.service - MongoDB Database Server + Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; preset: disabled) + Active: active (running) since Wed 2022-08-17 07:25:27 BST; 24h ago + Docs: https://docs.mongodb.org/manual + Main PID: 931 (mongod) + Memory: 304.1M + CPU: 2min 18.630s + CGroup: /system.slice/mongodb.service + └─931 /usr/bin/mongod --config /etc/mongodb.conf +Aug 17 07:25:27 archbish systemd[1]: Started MongoDB Database Server.**** +``` + +In addition to the core info it tells us the unit type. In this case it is a +service. + +We can also view the journal entry for the given unit. This provides you with +its diagnostic log messages: + +``` +journalctl --unit=mongodb.service +- Boot b9565dfe8aca4d069143209b3aa84d8e -- +Aug 05 18:31:30 archbish systemd[1]: Started MongoDB Database Server. +Aug 06 14:27:33 archbish systemd[1]: mongodb.service: Deactivated successfully. +Aug 06 14:27:33 archbish systemd[1]: mongodb.service: Consumed 3min 17.598s CPU time. +-- Boot 01922f84c3bd4b3a8f11824cf05f7320 -- +Aug 07 11:58:09 archbish systemd[1]: Started MongoDB Database Server. +Aug 08 14:43:01 archbish systemd[1]: mongodb.service: Deactivated successfully. +Aug 08 14:43:01 archbish systemd[1]: mongodb.service: Consumed 5min 28.760s CPU time. +-- Boot e52b735e115c43bdad8c00462aaff395 -- +Aug 10 13:13:22 archbish systemd[1]: Started MongoDB Database Server. +Aug 11 07:46:40 archbish systemd[1]: mongodb.service: Deactivated successfully. +Aug 11 07:46:40 archbish systemd[1]: mongodb.service: Consumed 2min 16.629s CPU time. +``` + +Each entry is organised around specific boots. diff --git a/zk/variables_in_c.md b/zk/variables_in_c.md new file mode 100644 index 0000000..b29b160 --- /dev/null +++ b/zk/variables_in_c.md @@ -0,0 +1,12 @@ +--- +id: r4i16p1x +title: Variables in C +tags: [C] +created: Thursday, February 29, 2024 | 17:20 +--- + +# Variables in C + +```c +int age = 25 +```