mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-30 22:57:59 +00:00
Update my cards and my notebook
Some additional notes on some tools I seem to use more frequently. Nothing unusual here.
This commit is contained in:
parent
f5dbb479bb
commit
59c2bb4cb1
105
cards/2021.org
105
cards/2021.org
@ -3,12 +3,13 @@
|
||||
:END:
|
||||
#+title: Anki: 2021
|
||||
#+date: "2021-05-01 20:20:25 +08:00"
|
||||
#+date_modified: "2021-05-16 13:58:36 +08:00"
|
||||
#+date_modified: "2021-05-21 12:09:04 +08:00"
|
||||
#+language: en
|
||||
#+property: anki_deck 2021
|
||||
#+property: header_args :exports both
|
||||
|
||||
#+name: lilypond-paper-config
|
||||
#+begin_src lilypond :exports none
|
||||
#+begin_src lilypond :exports none :results none
|
||||
\paper {
|
||||
indent=10\mm
|
||||
oddFooterMarkup=##f
|
||||
@ -484,6 +485,8 @@ Give various pitfalls and illusions of competence to look out when learning.
|
||||
- *The presence of the material itself* can cause students to foolishly think they already know about the subject.
|
||||
- Similarly, *studying with solutions can be a trap if you focus on the what and how rather than the why*.
|
||||
- Various common practices such as highlighting, rereading, and mind mapping are not as effective and only applicable in specific situations.
|
||||
- The einstellung mindset, *being invested in an idea that you can't see other solutions*.
|
||||
- Similarly, *overlearning can occur if you're aiming for complete mastery when you should move on after understanding the concept*.
|
||||
|
||||
* org-babel
|
||||
:PROPERTIES:
|
||||
@ -511,9 +514,6 @@ Among the list of features, org-babel makes the following things easier for crea
|
||||
** Front
|
||||
How to make org-babel pass values between different source code blocks?
|
||||
** Back
|
||||
:PROPERTIES:
|
||||
:ID: 5c959c6a-04fb-4154-becc-86eeb15b20ad
|
||||
:END:
|
||||
First, configure org-babel to work in functional mode (i.e., ~:results value~) in a source code block.
|
||||
With functional mode, it will return values which will be handled by org-babel.
|
||||
|
||||
@ -557,8 +557,7 @@ If so, how?
|
||||
** Back
|
||||
Yes!
|
||||
|
||||
With source code blocks and the [[https://orgmode.org/manual/Noweb-Reference-Syntax.html][noweb]] option enabled, you can make meta-programming in Org.
|
||||
You can declare a function by assigning a name on the code block (i.e., ~#+name: ${FUNC_NAME}~).
|
||||
By attaching a name to a code block and [[https://orgmode.org/manual/Evaluating-Code-Blocks.html#Evaluating-Code-Blocks][evaluating]] them, it is possible.
|
||||
|
||||
Here's an example of a source code block with a default argument.
|
||||
|
||||
@ -578,6 +577,7 @@ You can then call the function in different ways:
|
||||
|
||||
You can then pass header arguments by appending in square brackets (=[]=) before invoking it — e.g., ~call_greeting[:results replaces]()~, ~#+call: greeting[:results replace]()~, ~<<greeting[:results replace]()>>~.
|
||||
|
||||
|
||||
* Org mode: Asciidoctor-styled callouts
|
||||
:PROPERTIES:
|
||||
:ANKI_NOTE_TYPE: Styled cards
|
||||
@ -671,8 +671,6 @@ Give some ways how to navigate Org mode documents quickly.
|
||||
What function creates a buffer for certain elements in org-mode but it is especially useful for editing source code blocks where it will open with the correct major mode?
|
||||
** Back
|
||||
~org-edit-special~
|
||||
- The einstellung mindset, *being invested in an idea that you can't see other solutions*.
|
||||
- Similarly, *overlearning can occur if you're aiming for complete mastery when you should move on after understanding the concept*.
|
||||
|
||||
* Practices for studying
|
||||
:PROPERTIES:
|
||||
@ -804,8 +802,8 @@ What notes are displayed (in order)?
|
||||
#+results:
|
||||
[[file:assets/2021/basic-notation-reading-2.png]]
|
||||
|
||||
** Back
|
||||
A C major triad (i.e., C E G).
|
||||
** Back A
|
||||
C major triad (i.e., C E G).
|
||||
Then the notes E, F, and A.
|
||||
|
||||
* Basic music notation reading 3
|
||||
@ -828,3 +826,88 @@ What notes are displayed (in order)?
|
||||
|
||||
** Back
|
||||
C, D, C-A (a major sixth), E-B (a minor fifth), and G-F (a seventh).
|
||||
|
||||
* Watch the logs of a systemd unit
|
||||
:PROPERTIES:
|
||||
:ANKI_NOTE_TYPE: Styled cards
|
||||
:ANKI_NOTE_ID: 1621570139174
|
||||
:END:
|
||||
** Front
|
||||
What is happening with the following command?
|
||||
|
||||
#+begin_src shell :results none
|
||||
journalctl -u backup -fb
|
||||
#+end_src
|
||||
|
||||
** Back
|
||||
Watch the logs from the systemd unit ~backup.service~ starting from boot time.
|
||||
|
||||
The command could also be written in the same way.
|
||||
|
||||
#+begin_src shell :results none
|
||||
journalctl --unit backup --follow --boot
|
||||
#+end_src
|
||||
|
||||
* Restoring a file in Git
|
||||
:PROPERTIES:
|
||||
:ANKI_NOTE_TYPE: Styled cards
|
||||
:ANKI_NOTE_ID: 1621570139642
|
||||
:END:
|
||||
** Front
|
||||
How to restore a file in Git?
|
||||
** Back
|
||||
#+begin_src shell :results none
|
||||
git restore $FILE_PATH
|
||||
#+end_src
|
||||
|
||||
Despite the name, it will also delete the file if it's detected as untracked file in the Git worktree.
|
||||
|
||||
* Setting environment variables with systemd environment directive
|
||||
:PROPERTIES:
|
||||
:ANKI_NOTE_TYPE: Styled cards
|
||||
:ANKI_NOTE_ID: 1621570140918
|
||||
:END:
|
||||
** Front
|
||||
How to set environment variables with systemd?
|
||||
** Back
|
||||
Create an environment directive file in the specified directory.
|
||||
You can find the search paths and the syntax from =environment.d.5= manual page.
|
||||
|
||||
Basically, it is a shell-like config for setting environment variables.
|
||||
The following shows that.
|
||||
|
||||
#+begin_src shell :results none
|
||||
TERM=alacritty
|
||||
EDITOR=nvim
|
||||
BROWSER=brave
|
||||
MANPAGER="nvim +Man!"
|
||||
|
||||
PATH=${PATH:+$PATH:}${GUIX_PROFILE:-$HOME/.guix-profile}/bin
|
||||
XDG_DATA_DIRS=${GUIX_PROFILE:-$HOME/.guix-profile}/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
|
||||
#+end_src
|
||||
|
||||
Compared to exporting values with the user shell (e.g., =.bashrc=, =.zshrc=) where they are only applied when the shell is called, environment variables generated from the directive can be recognized from applications that called non-interactively (e.g., GNOME desktop search, Rofi).
|
||||
|
||||
You can also view the resulting environment with ~systemctl show-environment~.
|
||||
|
||||
* Emacs Lisp conditionals
|
||||
:PROPERTIES:
|
||||
:ANKI_NOTE_TYPE: Styled cards
|
||||
:ANKI_NOTE_ID: 1621570142444
|
||||
:END:
|
||||
** Front
|
||||
Give some functions for creating a conditional in Emacs Lisp.
|
||||
** Back
|
||||
Below are the common way to control the flow with Elisp.
|
||||
|
||||
#+begin_src elisp :results none
|
||||
(if (and nil nil)
|
||||
(message "Hello there!")
|
||||
(message "Not hello there, sith lord!"))
|
||||
|
||||
(unless t
|
||||
(message "Not hello there, sith lord!"))
|
||||
|
||||
(when t
|
||||
(message "Hello there!"))
|
||||
#+end_src
|
||||
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.6 KiB |
Binary file not shown.
54
structured/cli.journalctl.org
Normal file
54
structured/cli.journalctl.org
Normal file
@ -0,0 +1,54 @@
|
||||
#+title: journalctl
|
||||
#+date: "2021-05-20 23:07:39 +08:00"
|
||||
#+date_modified: "2021-05-20 23:27:03 +08:00"
|
||||
#+language: en
|
||||
#+property: header-args :results none
|
||||
|
||||
|
||||
The logging daemon of systemd.
|
||||
(Ooooh...)
|
||||
Not only it can view your logs, you can ask to view specific logs and delete some of them.
|
||||
|
||||
For more information, see =journalctl.1= manual page.
|
||||
|
||||
|
||||
|
||||
|
||||
* Options
|
||||
|
||||
- ~-b, --boot~ - show the logs starting from boot time
|
||||
- ~-e, --pager-end~ - go to the end of the logs
|
||||
- ~-f, --follow~ - watch the logs
|
||||
- ~--user-unit~ - show logs from a user unit
|
||||
- ~-u, --unit [UNIT]~ - show the logs of a system unit
|
||||
- ~--vacuum-time=[TIMESPAN]~ - delete logs older than the specified timespan [fn:: View =systemd.time.5= for more information.]
|
||||
- ~-x, --catalog~ - prints helpful messages such as the documentation URIs
|
||||
|
||||
|
||||
|
||||
|
||||
* Examples
|
||||
|
||||
This tool is already comprehensive.
|
||||
Needs a comprehensive database of examples to fight against this scope.
|
||||
|
||||
|
||||
** Watch the logs from a specific unit at boot time
|
||||
|
||||
#+begin_src shell
|
||||
journalctl --user-unit borgbackup.service -fb
|
||||
#+end_src
|
||||
|
||||
|
||||
** Delete the logs older than a month
|
||||
|
||||
#+begin_src shell
|
||||
journalctl --vacuum-time=1m
|
||||
#+end_src
|
||||
|
||||
|
||||
** View the latest logs with helpful messages
|
||||
|
||||
#+begin_src shell
|
||||
journalctl -xe
|
||||
#+end_src
|
13
structured/data.wikidata.org
Normal file
13
structured/data.wikidata.org
Normal file
@ -0,0 +1,13 @@
|
||||
#+title: Wikidata
|
||||
#+date: "2021-05-20 21:14:34 +08:00"
|
||||
#+date_modified: "2021-05-20 21:15:24 +08:00"
|
||||
#+language: en
|
||||
|
||||
|
||||
- A universal database with semi-structured data allowing for natural queries.
|
||||
- Each item in the database contains statements which in turn contain properties.
|
||||
- Querying tools are available (e.g., https://query.wikidata.org/, wikibase-cli).
|
||||
- item + statement + property
|
||||
- The item itself and its part are assigned a unique ID — e.g., the item "GNU Guix" is assigned to "Q18968627" and it has a logo image statement is which assigned at "P154".
|
||||
- Wikidata-related SDKs and APIs are available for interacting with the data without using the website.
|
||||
- [[https://www.wikidata.org/wiki/Special:ApiSandbox][API sandbox]]
|
60
structured/sysadmin.systemd.org
Normal file
60
structured/sysadmin.systemd.org
Normal file
@ -0,0 +1,60 @@
|
||||
#+title: Exploring systemd features
|
||||
#+date: "2021-05-20 22:37:22 +08:00"
|
||||
#+date_modified: "2021-05-20 22:59:53 +08:00"
|
||||
#+language: en
|
||||
|
||||
|
||||
systemd is a big tool for a big system.
|
||||
Let's explore some of them from a perspective of a wannabe power user.
|
||||
|
||||
|
||||
|
||||
|
||||
* systemd at user-level
|
||||
|
||||
systemd has the ability to run at user-level empowering the user to manage their own system with their own settings.
|
||||
It immensely helps separating user-specific settings from the system-wide settings.
|
||||
|
||||
systemd looks for the units from certain paths.
|
||||
You can look for them from the =systemd.unit.5= manual page.
|
||||
|
||||
To run systemd as a user instance, simply add a =--user= flag beforehand for =systemctl= and other systemd binaries, if applicable.
|
||||
|
||||
#+begin_src shell :results none
|
||||
systemctl --user show-units
|
||||
systemctl --user show-environment
|
||||
systemctl --user start $SERVICE
|
||||
#+end_src
|
||||
|
||||
|
||||
|
||||
|
||||
* Timers as cron replacement
|
||||
|
||||
You can schedule tasks with timers.
|
||||
If systemd is compiled with the feature, it makes cron unnecessary.
|
||||
|
||||
systemd has different ways to denote time.
|
||||
|
||||
- Timespans denote the duration — e.g., =100 seconds=, =5M 3w=.
|
||||
- Timestamps refer to a specific point in time — e.g., =2021-04-02=, =today=, =now=.
|
||||
- Calendar events can refer to more than one point of time — e.g., =*-*-4/2=, =Sun,Wed,Fri *-1/2-1/8=.
|
||||
|
||||
Here's an example of setting a timer for an example backup service.
|
||||
The following timer unit sets it to execute every day at 18:00.
|
||||
|
||||
#+begin_src
|
||||
[Unit]
|
||||
Description=A deduplicated backup from my computer
|
||||
Documentation=man:borg(1) https://borgbackup.readthedocs.io/
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* 18:00:00
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical.target
|
||||
#+end_src
|
||||
|
||||
You can find more information about it from the =systemd.time.5= manual page.
|
||||
Furthermore, systemd has a testing tool for time with ~systemd-analyze {timespan,timestamp,calendar}~.
|
Loading…
Reference in New Issue
Block a user