From 5355a8c14427e8a2d200feb0c5de73dd550cb17c Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Fri, 7 May 2021 12:11:25 +0800 Subject: [PATCH] Update cards, documentation, and dependencies --- README.adoc | 16 +++++- cards/emacs.org | 44 +++++++++++++++- cards/linux.org | 64 ++++++++++++++++++++++- cards/org-mode.org | 128 +++++++++++++++++++++++++++++++++++++++++++++ cards/vim.org | 54 ++++++++++++++++++- index.org | 7 ++- references.bib | 10 ++++ shell.nix | 1 + 8 files changed, 315 insertions(+), 9 deletions(-) create mode 100644 cards/org-mode.org diff --git a/README.adoc b/README.adoc index 4b647fb..f911ad3 100644 --- a/README.adoc +++ b/README.adoc @@ -24,6 +24,20 @@ Fortunately for me, most of the private files are connected with each other (a s +== Why set up like this? + +We need to focus on why did I need to make the structure like this. +For this question, I answer with the outcomes that I expect from the note-taking system I eventually settled with. + +- I want ideas to be searched and woven so easily with the rest. +- I'm not an expert so I still need the "basic" way of taking structured notes, summarizing them until I gain a bigger picture of the things I'm curious about. +- I want to easily integrate spaced repetition and randomness to encourage improvement on my notes. + +This project is the result of that with org-roam, Anki, and eventually more (preferably less) tools to stick around and gain ideas from. + + + + == Getting started Interested in copying my setup? @@ -128,7 +142,7 @@ Here's an example Doom Emacs configuration for that: (add-hook 'before-save-hook 'time-stamp) ---- + -Just see my link:https://github.com/foo-dogsquared/dotfiles/tree/4e8f036b73a71d02f5909f4f28898a79c2311147/emacs[Doom Emacs config] in my dotfiles. +Just see my link:https://github.com/foo-dogsquared/dotfiles/tree/75de71b4d0dfe79fe820204e365809cee11d7349/emacs[Doom Emacs config] in my dotfiles. * The related assets are stored in the link:./assets/[`./assets/`]. The asset folder names should be the same as the filename of the org-mode document — e.g., `2021-04-06-15-04-11.org` should have an asset folder in `./assets/2021-04-06-15-04-11/`. diff --git a/cards/emacs.org b/cards/emacs.org index f090e25..b759a27 100644 --- a/cards/emacs.org +++ b/cards/emacs.org @@ -3,7 +3,7 @@ :END: #+title: Anki: Emacs #+date: "2021-05-02 19:18:32 +08:00" -#+date_modified: "2021-05-04 20:51:29 +08:00" +#+date_modified: "2021-05-06 21:57:59 +08:00" #+language: en #+property: anki_deck Emacs @@ -74,3 +74,45 @@ if the buffer is modified in one of the window, it will show the changes in all A marker is another point in the buffer. It is usually found when interacting with regions when asked for the two points (i.e., the beginning and the ending position). Furthermore, a marker can be used to save locations and jump back to that marker when asked. + +* Interacting with buffers in Elisp +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620309319576 +:END: +** Front +Give a rough example on how to do the following. + +- Create a temporary buffer containing the text "Hello world". +- Name the buffer and open it as an Org mode document. +- Get or create the ID for the document. +** Back +#+begin_src elisp :exports code +(with-temp-buffer + (insert "Hello world") + (org-mode)) +#+end_src + +* String comparison in Emacs Lisp +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620309321231 +:END: +** Front +How to compare two strings? +** Back +~(string= STR1 STR2)~ + +#+begin_src elisp +(print (string= "WHOA" "whoa")) +(print (string= "WHOA" (upcase "whoa"))) +(print (string= "Hello world" "HeLL0 World")) +#+end_src + +#+results: +: +: nil +: +: t +: +: nil diff --git a/cards/linux.org b/cards/linux.org index bd76a8c..590ae76 100644 --- a/cards/linux.org +++ b/cards/linux.org @@ -3,7 +3,7 @@ :END: #+title: Anki: Linux #+date: "2021-05-01 20:20:25 +08:00" -#+date_modified: "2021-05-04 20:51:29 +08:00" +#+date_modified: "2021-05-06 18:33:03 +08:00" #+language: en #+property: anki_deck Linux @@ -41,3 +41,65 @@ How to test out systemd timestamps? ~systemd-analyze {calendar,timestamp,timespan}~ To know how the format (i.e., calendar, timestamp, and timespan) looks like, you can refer to ~man systemd.time.5~. + +* Enabling desktop integration +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620296263978 +:END: +** Front +How to make desktop environments recognize the desktop files? +** Back +Most of the desktop environments and certain applications like Rofi refers to the ~XDG_DATA_DIRS~ environment variable, a list of colon-delimited paths similar to ~PATH~. + +This enables desktop integration with certain tools like [[https://nixos.org/][Nix]] and [[https://guix.gnu.org/][Guix]] package manager. +Here's how to integrate installed Nix packages into the desktop. + +#+begin_src shell +XDG_DATA_DIRS=$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share} +#+end_src + +* Flatpak permissions +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620296265390 +:END: +** Front +What permissions does user-installed Flatpak apps have by default? +** Back +By default, they have none. +[[https://docs.flatpak.org/en/latest/sandbox-permissions.html][Among the default limitations]]: + +- They can only access their own runtime folder =$HOME/.var/app/${FLATPAK_APP_ID}=. +- They cannot access the network. + +Some apps are installed with the request to allow the following permissions enabled (e.g., Zotero). + +If left with no permissions, you'll see in certain situations like a file browser dialog that the permissions is in effect. +Below are some of the examples interacting with the permissions of an app. + +#+begin_src shell +# Show the permissions of an app. +flatpak permission-show ${FLATPAK_APP_ID} + +# Let the user-installed Flatpak app access the home directory. +flatpak override --user --filesystem=home ${FLATPAK_APP_ID} +#+end_src + +* The basics of Flatpak apps +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620296265848 +:END: +** Front +What is a Flatpak package? +Does it have its own form of managing dependencies? +** Back +A Flatpak package can either be a runtime or a standalone app. + +Runtimes are the basic dependencies of an application. +Only select packages available as a runtime (e.g., Qt, GTK). + +Flatpak has its set of runtimes composed of system libraries to be used with the applications. +Thus, it stays out of its way with the operating system's libraries. +The developer can also bundle its own set of libraries. diff --git a/cards/org-mode.org b/cards/org-mode.org new file mode 100644 index 0000000..4d041c7 --- /dev/null +++ b/cards/org-mode.org @@ -0,0 +1,128 @@ +:PROPERTIES: +:ID: b804fe54-d7f4-4809-be9e-50779b4b9314 +:ANKI_DECK: Emacs +:END: +#+title: Anki: Org mode +#+date: "2021-05-05 22:49:10 +08:00" +#+date_modified: "2021-05-06 01:42:46 +08:00" +#+language: en + +* org-babel +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620236488535 +:END: +** Front +What makes Org mode popular for reproducible research? +** Back +org-babel, the library that enables superpowers for Org mode source code blocks. + +Among the list of features, org-babel makes the following things easier for creating lab notebooks. + +- Execute the source code block and print results. +- Create files from source code blocks, making it possible to create an entire computational report with a single Org mode document. +- Metaprogramming with [[https://orgmode.org/manual/Noweb-Reference-Syntax.html][noweb-inspired system]] making dynamic content possible. +- Individual control over source code blocks with sessions, export options, and variables. +- Pass values between different source code blocks even in different programming languages. + +* org-babel modes +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620236489830 +:END: +** 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. + +#+begin_src org +,#+name: num +,#+begin_src python :results value +return 53 +,#+end_src +#+end_src + +The value cannot be passed unless it has a name that others can reference yet so add a name property to the source code block (i.e., ~#+name: ${NAME}~). + +Now here's a different source code block written in a different language. +To pass a value, you have to configure with ~:var ${VARNAME}=${NAME}~. + +#+begin_src org +,#+begin_src ruby :var num=num :results output +print(num) +,#+end_src +#+end_src + +* Creating files with Org mode +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620236490049 +:END: +** Front +How to create files with Org mode source code blocks? +** Back +The ~:tangle~ option enables extracting code blocks into files. +Accepted values include =yes=, =no=, or a relative path to the Org document where the file will be written. + +* Dynamic content with Org mode +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620236491388 +:END: +** Front +Is creating dynamic content possible? +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}~). + +Here's an example of a source code block with a default argument. + +#+begin_src org +,#+name: greeting +,#+header: :var name="World" +,#+begin_src sh +echo "Hello ${name}" +,#+end_src +#+end_src + +You can then call the function in different ways: + +- For calling it inline, ~call_${FUNC_NAME}()~. +- For creating a block, ~#+call: ${FUNC_NAME}()~. +- For invoking inside a code block, ~<<${FUNC_NAME}()>>~, but you have to enable noweb (e.g., ~:noweb yes~). + +You can then pass header arguments by appending in square brackets (=[]=) before invoking it — e.g., ~call_greeting[:results replaces]()~, ~#+call: greeting[:results replace]()~, ~<>~. + +* Asciidoctor-styled callouts +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620236492755 +:END: +** Front +Are callouts possible? +If so, how? +** Back +Surprisingly, yes! +It is just hidden on the documentation. +Specifically, on the [[https://orgmode.org/manual/Literal-Examples.html][Literal examples]] section of the Org mode manual. + +Here's an example to do it. + +#+begin_src org +,#+begin_src python +print("Hello world") # (ref:hello) +print(2 + 5) # (ref:num) +,#+end_src + +In [[(hello)][line 1]], we have printed the traditional "Hello world" program. +In [[(num)][the second line]], we've done a simple arithmetic and printed it into the console. +#+end_src + +To create Asciidoctor-styled callouts, create a reference inside of the code block and refer to it (i.e., ~(${ref})~). diff --git a/cards/vim.org b/cards/vim.org index 5b01a9a..bf3f16e 100644 --- a/cards/vim.org +++ b/cards/vim.org @@ -3,7 +3,7 @@ :END: #+title: Anki: Vim #+date: "2021-05-01 17:52:58 +08:00" -#+date_modified: "2021-05-04 20:51:30 +08:00" +#+date_modified: "2021-05-06 21:58:16 +08:00" #+language: en #+property: anki_deck Vim @@ -38,7 +38,7 @@ How to jump into a keyword? ** Front How to go to the file path at point? ** Back -=gf= as in *goto file*. +=gf= (in normal mode) as in *goto file*. * Set as a pager :PROPERTIES: @@ -80,3 +80,53 @@ A filetype is how Vim knows what plugins to apply to the current buffer. Vim has a few built-in filetypes such as shell, manual pages, Markdown, Asciidoc, xmodmap, patch files, and JSON among others (that are in =$VIMRUNTIME/filetype.vim=). For more information, run ~:help filetype~ inside Vim. + +* Going to keyword definitions +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620225232521 +:END: +** Front +How to go to the keyword definition? +** Back +=gd= as in *go to definition*. + +Though, not all the time it will do what its supposed to do. +For better effect, you can generate a Ctags file which Vim has a built-in integration (see ~:h ctags~). + +* Vim modes +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620225233076 +:END: +** Front +What is a mode (in Vim)? +** Back +A Vim mode is a set of behavior and actions. +In this case, it considers editing and navigation (among other modes) to be separate. +Thus, you need to switch between them to do those things. + +Vim has built-in modes which you can see with ~:h vim-modes~. + +* Word wrapping +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620309338874 +:END: +** Front +How to do word wrapping? +** Back +=gw= as in *go format the words*. +By default, it simply line wraps the lines with the 80-character limitation. + +* Using the help system +:PROPERTIES: +:ANKI_NOTE_TYPE: Styled cards +:ANKI_NOTE_ID: 1620309339153 +:END: +** Front +How to effectively make use of the help system? +** Back +The usual way is to execute ~:h~ or ~:help~. +You can view what does a keybinding do with ~:h ${KEYBINDING}~ — e.g., ~:h gw~ to know what =gw= does, ~:h V~ for viewing visual line mode. +For keybindings in visual and command line mode, prepend them with ~v_~ and ~c_~, respectively. diff --git a/index.org b/index.org index 487e7ab..23150a3 100755 --- a/index.org +++ b/index.org @@ -2,13 +2,9 @@ :ID: e9fa93ca-b4fb-44b8-ad3c-d10107150697 :END: #+TITLE: Index -#+AUTHOR: "Gabriel Arazas" -#+EMAIL: "foo.dogsquared@gmail.com" #+DATE: "2020-09-07 05:49:06 +08:00" #+DATE_MODIFIED: "2020-09-09 05:49:21 +08:00" #+LANGUAGE: en -#+OPTIONS: toc:t -#+PROPERTY: header-args :exports both Hello! @@ -16,3 +12,6 @@ This is my public knowledge graph publicly available for the public. It is mostly intended for easy access for my notes in case I'm not in my computer along with sharing my findings with the rest of the world (and hopefully getting feedback on it). If you want to view my notes in its raw form, you can look at the [[http://github.com/foo-dogsquared/wiki][Git repo]]. +There's no good index note yet so eeeeeeeeeeeeeehhhhhhhhhhhhhhhhhhhhh... + +As of 2021-05-07, my interest is in document [[roam:Personal information management]], [[roam:Illustration]], package management, and programming. diff --git a/references.bib b/references.bib index 6b0f872..4989058 100644 --- a/references.bib +++ b/references.bib @@ -204,6 +204,16 @@ keywords = {data-mining} } +@video{spudlyoConsistentTechnicalDocuments2019, + title = {Consistent {{Technical Documents Using Emacs}} and {{Org Mode}}}, + editor = {{spudlyo}}, + date = {2019-11-17}, + url = {https://www.youtube.com/watch?v=0g9BcZvQbXU&t=851s}, + urldate = {2021-05-05}, + abstract = {Files used in the demo: https://gitlab.com/spudlyo/orgdemo\mbox{} My dotfiles: https://gitlab.com/spudlyo/dotfiles\mbox{} Read The Org: https://github.com/fniessen/org-html-...\mbox{} Read The Docs: https://sphinx-rtd-theme.readthedocs....\mbox{} Git from the Bits Up: https://www.youtube.com/watch?v=MYP56...\mbox}, + editortype = {director} +} + @unpublished{stevenpinkerLinguisticsStyleWriting2015, title = {Linguistics, {{Style}} and {{Writing}} in the 21st {{Century}} - with {{Steven Pinker}}}, author = {{Steven Pinker}}, diff --git a/shell.nix b/shell.nix index be19bb4..d5a4127 100644 --- a/shell.nix +++ b/shell.nix @@ -10,5 +10,6 @@ pkgs.mkShell { python3 racket R + recoll ]; }