diff --git a/2020-06-27-16-21-47.org b/2020-06-27-16-21-47.org index e986f30..5bccf30 100644 --- a/2020-06-27-16-21-47.org +++ b/2020-06-27-16-21-47.org @@ -3,14 +3,13 @@ :END: #+title: Apply search tools and techniques for your digital library #+date: "2020-06-27 16:21:47 +08:00" -#+date_modified: "2021-05-04 20:52:15 +08:00" +#+date_modified: "2021-07-11 20:10:35 +08:00" #+language: en #+tags: personal-info-management With digital files comes digital tools (and some techniques) to help us in searching for our notes. -These can vary from complex technologies to simple format-agnostic techniques that can make querying files with specific information to be a breeze. -[fn:: If you want to maintain your personal digital library, make sure to document how you work. +These can vary from complex technologies to simple format-agnostic techniques that can make querying files with specific information to be a breeze. [fn:: If you want to maintain your personal digital library, make sure to document how you work. Your future self will thank you later.] In order to search effectively, you need to consider [[id:ea263f6f-fa8e-4e6d-a585-d30d493d1e3c][Desktop search engines]] that can also search [[id:ccb3bc14-a801-4ed0-b066-50b1bcd853aa][File metadata]]. diff --git a/2020-09-04-16-07-47.org b/2020-09-04-16-07-47.org index 056868a..e0098ae 100644 --- a/2020-09-04-16-07-47.org +++ b/2020-09-04-16-07-47.org @@ -3,14 +3,14 @@ :END: #+title: Nix package manager #+date: "2020-09-04 16:07:47 +08:00" -#+date_modified: "2021-05-04 20:52:09 +08:00" +#+date_modified: "2021-06-11 10:54:42 +08:00" #+language: en [[https://nixos.org/][Nix]] is a package manager that pioneered [[id:bfed6daf-4c2b-4426-bab9-2804caa5e079][Functional package management]] which addresses the criticisms of traditional Unix systems while making it as a specialized tool for [[id:6eeb7a24-b662-46d6-9ece-00a5028ff4d8][Reproducible research]]. -Holistically, Nix is made up of at least four components: the store, the language, the derivations, and the sandbox. +It features a handrolled configuration language (also called Nix) that leans into functional paradigm, making it easier if you have experience on it. +A popular tool mostly featured in Haskell programming projects. -- The store is a immutable centralized location where all of the outputs are placed. -- The derivations are essentially build instructions. -- The language (also called as Nix but we'll refer to it as Nixlang) is a domain-specific language for creating derivations. -- The build process can be locked in a sandbox, improving the reproducibility of a setup and lowering the attack surface for a malicious package. +Eventually inspired GNU to create a fork, [[id:be917383-84c4-4bf5-9ca0-b04bfb778f4f][Guix package manager]], that takes it to another direction with more focus on reproducibility and its extensions such as bootstrapping. + +To see more details, refer to [[id:892676b3-76cb-4cd4-9689-910c1fe6587a][The basics of Nix package manager]]. diff --git a/2020-09-11-04-08-34.org b/2020-09-11-04-08-34.org index 9f3db45..87d81bf 100644 --- a/2020-09-11-04-08-34.org +++ b/2020-09-11-04-08-34.org @@ -3,12 +3,10 @@ :END: #+title: Human-friendly color spaces #+date: "2020-09-11 04:08:34 +08:00" -#+date_modified: "2021-05-04 20:52:16 +08:00" +#+date_modified: "2021-05-22 10:18:03 +08:00" #+language: en -- Tags :: [[id:4f6ec65b-4a05-4448-83f1-2f8f61781fe7][Computer graphics]] - As it turns out (from my perspective), different colorspaces have different purposes. - Screens usually use sRGB for consistency despite technology is advancing enough to create more capabilities for display. diff --git a/2020-09-19-08-31-48.org b/2020-09-19-08-31-48.org index 252cdf6..8a711d7 100644 --- a/2020-09-19-08-31-48.org +++ b/2020-09-19-08-31-48.org @@ -3,15 +3,13 @@ :END: #+title: Functional package management #+date: "2020-09-19 08:31:48 +08:00" -#+date_modified: "2021-05-04 20:52:16 +08:00" +#+date_modified: "2021-06-05 20:35:30 +08:00" #+language: en -Functional package management (FPM) is the next step forward [[https://edolstra.github.io/pubs/nixos-icfp2008-final.pdf][pioneered by Eelco Dolstra]] with [[https://nixos.org/][NixOS]] as the living implementation. -[fn:: Eventually, it became the inspiration for other projects that focuses on reproducibility and security such as [[https://guix.gnu.org/][GNU Guix]] and [[https://silverblue.fedoraproject.org/][Fedora Silverblue]].] +Functional package management (FPM) is the next step forward [[https://edolstra.github.io/pubs/nixos-icfp2008-final.pdf][pioneered by Eelco Dolstra]] with [[id:3b3fdcbf-eb40-4c89-81f3-9d937a0be53c][Nix package manager]] as the living implementation. [fn:: Eventually, it became the inspiration for other projects that focuses on reproducibility and security such as [[https://guix.gnu.org/][GNU Guix]] and [[https://silverblue.fedoraproject.org/][Fedora Silverblue]].] The conceptual overview of it is similar to [[id:7e1e2bcc-6f70-4624-a049-b42f9db5e28b][Functional programming]] with how it views with data and functions (in this case, packages and build processes). - It views that packages are a unique result from combining different things: dependencies, build processes, versions, and more. If a dependency has updated its patch version or a build instruction has revised with one line of change, it will result in a "new" package as the output even if the package isn't any different. @@ -21,9 +19,9 @@ The problems that FPM attempts to solve come from the critique of the traditiona Here are some of the problems on a traditional Linux-based system: - The statefulness of the entire system leads to similar situations on Windows' dependency hell problem. +- As a consequence of the statefulness, traceability is almost non-existent. - Multiple versions of packages are hard to place side-by-side which is used by developers targetting stable versions while experimenting with the latest versions. - Destructive ongoing updates which consists of replacing the current version with the updated version while the update is going. -- Traceability is almost non-existent with all of the statefulness of the system. The functional approach with the unique output and immutable variables addresses the listed problems in some way. diff --git a/2021-04-05-12-51-56.org b/2021-04-05-12-51-56.org index c62d177..428b73e 100644 --- a/2021-04-05-12-51-56.org +++ b/2021-04-05-12-51-56.org @@ -3,13 +3,11 @@ :END: #+title: Speedreading #+date: "2021-04-05 12:51:56 +08:00" -#+date_modified: "2021-05-04 20:52:07 +08:00" +#+date_modified: "2021-06-05 20:56:09 +08:00" #+language: en #+tags: personal-info-management -- [[https://www.scotthyoung.com/blog/2015/01/19/speed-reading-redo/]] - The act of reading faster than the average speed. One of the common methods in shutting off your inner reading voice and replacing it with visualizing words as you read along. diff --git a/cards/2021.org b/cards/2021.org index 025fdc3..13a813c 100644 --- a/cards/2021.org +++ b/cards/2021.org @@ -3,7 +3,7 @@ :END: #+title: Anki: 2021 #+date: "2021-05-01 20:20:25 +08:00" -#+date_modified: "2021-06-18 22:12:31 +08:00" +#+date_modified: "2021-07-17 17:57:25 +08:00" #+language: en #+property: anki_deck 2021 #+property: header_args :exports both @@ -131,7 +131,7 @@ How to change user shell in most Linux distros? :ANKI_NOTE_ID: 1620896955274 :END: ** Front -Give some ways to print a list. +Give some ways to print a list in the shell. ** Back #+begin_src shell # Format the string. @@ -1028,7 +1028,7 @@ Give the list of practices and their summary from the SUSE Cloud native fundamen - *Knowing the resource consumption is good for assessing whether the application is ready.* Examples include monitoring the CPU and memory consumption during a service and creating benchmarks. -For easier memorizing, we can use the phrase "Healthy metrics leaves the logs a trace of resource consumption." +For easier memorizing, we can use the phrase "A healthy metric of logs traces resource consumption." If you're deploying a web application, for example, you may assign certain routes for some of the above practices — e.g., =/status/= for health checks, =/metrics/= to create a metrics dashboard. diff --git a/structured/cli.borg.org b/structured/cli.borg.org index e975260..e8c4a0f 100644 --- a/structured/cli.borg.org +++ b/structured/cli.borg.org @@ -3,7 +3,7 @@ :END: #+title: Command line: BorgBackup #+date: "2021-05-30 21:40:24 +08:00" -#+date_modified: "2021-07-08 17:56:25 +08:00" +#+date_modified: "2021-07-13 22:54:32 +08:00" #+language: en #+property: header_args :eval no #+property: header_args:bash :results silent :exports code @@ -37,8 +37,8 @@ It can be picky with certain subcommands output being affected from the order of Borg uses a Git-style command-line interface with subcommands and some common options to choose from. - You can set the log level of the program with =--debug=, =--info=, =--warning=, =--error=, and =--critical=. -- =-v, --verbose= - alias for =--info= -- =-p, --progress= - show progress information; will be slower on certain operations due to additional passing of the metadata +- =-v, --verbose= is an alias for =--info= +- =-p, --progress= shows progress information; will be slower on certain operations due to additional passing of the metadata Keep in mind, Borg doesn't have global configuration files, only per-repo configurations. You can create configurations with a little hard work and shell scripts. diff --git a/structured/cli.youtube-dl.org b/structured/cli.youtube-dl.org index 817b467..c155704 100644 --- a/structured/cli.youtube-dl.org +++ b/structured/cli.youtube-dl.org @@ -1,6 +1,6 @@ #+title: Command-line: youtube-dl #+date: "2021-07-08 17:36:26 +08:00" -#+date_modified: "2021-07-08 19:02:10 +08:00" +#+date_modified: "2021-07-13 22:56:11 +08:00" #+language: en #+property: header-args :eval no @@ -22,16 +22,44 @@ youtube-dl [OPTIONS...] [URLS...] * Options -- =--add-metadata= - add metadata to the resulting file -- =--audio-format [EXTENSION]= - download the video with the select format of "opus", "mp3", "opus", and "vorbis"; but there is also the convenient "best" option -- =--audio-quality [QUALITY]= - quality of the audio from 0 to 9, best to worst respectively; bitrates are also accepted (e.g., =320K=, =1M=) -- =--config-location [PATH]= - set the config to be used; useful for local configs with specific options -- =-F, --list-format= - prints a list of format available for downloading -- =--format [QUALITY]= - download the video with the format shown in =--list-format=; there are convenient options such as =bestaudio= and =bestvideo= referring to the best quality it could find -- =-j, --dump-json= - dry-run and prints in JSON format -- =--no-overwrite= - error if the file already exists which is handy for scripts -- =--write-sub= - writes the subtitle file into disk -- =-x, --extract-audio= - extract only the audio track +- =--add-metadata= adds metadata to the resulting file after download +- =--audio-format [EXTENSION]= downloads the video with the select format of "opus", "mp3", "opus", and "vorbis"; but there is also the convenient "best" option +- =--audio-quality [QUALITY]= sets the quality of the audio from 0 to 9, best to worst respectively; bitrates are also accepted (e.g., =320K=, =1M=) +- =-c, --continue= resumes the download; useful if the download process is interrupted +- =--config-location [PATH]= set the config to be used; useful for local configs with specific options +- =-F, --list-format= prints a list of format available for downloading +- =--list-extractors= prints a list of supported sites and their specific features. +- =--format [QUALITY]= downloads the video with the format shown in =--list-format=; there are convenient options such as =bestaudio= and =bestvideo= referring to the best quality it could find +- =-j, --dump-json= completes a dry-run and prints in JSON format +- =-o, --output [STRING]= formats the resulting filename of the tracks to be downloaded +- =--no-overwrite= throws an error if the file already exists which is handy for scripts +- =--write-sub= writes the subtitle file into disk +- =-x, --extract-audio= extracts only the audio track + + +** Output formats + +For =--output= option, there are a lot of things to consider naming your files. +You may want to automate them yourself but =youtube-dl= has plenty of options from the get-go. + +The following code is the sensible default output string. + +#+begin_src +%(playlist_index)02d-%(title)s.%(ext)s +#+end_src + +A few of the usual stuff I use: + +- =title= (string) is the title of the track +- =ext= (string) is the extension to be used; pretty much recommended to use it + +A lot of the things I have to do is to download multiple tracks from an album or playlist. +Unfortunately, these are often different from one site to another. + +- =playlist_index= (number) indicates the position of the track in a playlist. + These are usually used from YouTube and Soundcloud playlists. +- =track_number= (number) is the position of the track from an album. + Usually, these are used from Bandcamp and Vimeo playlists. @@ -58,7 +86,7 @@ Though, you should look at the supported sites if it supports downloading an alb In this example, we have Bandcamp. #+begin_src shell -youtube-dl --output '%(title)s.%(ext)s' --format bestaudio https://gametal.bandcamp.com/album/side-quests-vol-3 +youtube-dl --output '%(track_number)02d-%(title)s.%(ext)s' --format bestaudio https://gametal.bandcamp.com/album/side-quests-vol-3 #+end_src diff --git a/structured/editor.neovim.lua.org b/structured/editor.neovim.lua.org new file mode 100644 index 0000000..e79a3bd --- /dev/null +++ b/structured/editor.neovim.lua.org @@ -0,0 +1,31 @@ +#+title: Neovim Lua integration +#+date: "2021-07-15 07:45:50 +08:00" +#+date_modified: "2021-07-15 08:38:24 +08:00" +#+language: en + + +- [[https://github.com/nanotee/nvim-lua-guide][go-to resource when introducing using Lua into Neovim]] +- similar to VimL configs, really +- init file is =${XDG_CONFIG_HOME}/nvim/init.lua= +- Lua configs doesn't configure much by default +- you can start with =lua-intro= help section in the =lua= help page from Neovim — i.e., =:h lua= +- you can still execute Vimscript with =vim.cmd=; + more information is at =:h lua-vimscript= +- basics from VimL + + to set options, it's mostly in =vim.opt= — e.g., ~set number relativenumber~ versus ~vim.opt.number, vim.opt.relativenumber = true, true~ + + highlight options are mostly in =vim.highlight= — e.g., ~highlight clear SpellCap~ versus ~vim.highlight~ + + to set local options, use =vim.opt_local= — e.g., ~setlocal spell~ versus ~vim.opt_local.spell = true~ + + otherwise, to set global options, use =vim.opt_global= + + you can access environment variables through =vim.env= — e.g., ~vim.env.HOME~, ~vim.env.MYVIMRC~ + + you can manipulate variables of various scales from =vim.{g,b,t}=; + to see more details, see =lua-vim-variables= help section + + =vim.opt= will return an Option object, it has a common API; + to learn more about it, see =vim.opt= and its subsections + + to run Vimscript, you can use =vim.cmd= — e.g., ~vim.cmd "colorscheme nord"~ +- there are Neovim configurations written in Lua + + [[https://github.com/mjlbach/defaults.nvim][defaults.nvim]] +- comprehensive examples include Neovim plugins that are already written in Lua + + [[https://github.com/savq/paq-nvim][paq-nvim]] is a simple Neovim package manager + + [[https://github.com/wbthomason/packer.nvim][packer.nvim]] is a more comprehensive package manager + + [[https://github.com/L3MON4D3/LuaSnip][LuaSnip]] is a snippet engine + + [[https://github.com/nvim-telescope/telescope.nvim][telescope.nvim]] is a fuzzy finder integrated inside Neovim diff --git a/structured/lang.oil.org b/structured/lang.oil.org index ed35c01..5d0fc66 100644 --- a/structured/lang.oil.org +++ b/structured/lang.oil.org @@ -1,12 +1,12 @@ -#+title: Oil shell +#+title: Oil shell language #+date: "2021-05-09 16:40:50 +08:00" -#+date_modified: "2021-06-23 20:12:37 +08:00" +#+date_modified: "2021-07-13 23:32:05 +08:00" #+language: en #+property: header-args:oil :eval no For future references, this note mainly notes Oil v0.8.11 and later versions. -Also, we'll be comparing to Bash shell (src_bash[:eval yes :results output]{bash --version}) as it is the most popular shell on the Unix world. +Also, we'll be comparing to Bash shell (src_bash[:eval yes :results output]{bash --version | head -n 1} {{{results(=GNU bash\, version 4.4.23(1)-release (x86_64-unknown-linux-gnu)=)}}}) as it is the most popular shell on the Unix world. @@ -196,6 +196,8 @@ if ('rainy' in conditions) { + *command mode is similar to Bash expressions* + *expression mode is akin to Python expressions* +- Expression mode even has Python familiarisms — e.g., ~if ("item" in array)~, ~if ("key" in object)~. + - The addition of a Python-like expressiveness is how Oil can make a rich scripting exprience. - command mode is what you see most of the time @@ -222,6 +224,48 @@ write -- $'\u044f\u043c\u0443' $'\u3bc' +* Structured data + +While Bash have support for structured data such as arrays and associative arrays, it does not go any further such as not letting you assign arrays in an item. +As of v0.8.9, Oil also comes with the same problem but it seems [[https://github.com/oilshell/oil/issues/741][the developer is also interested in solving that]]. + +Though, you can still declare and assign variables with nested data structures. + +#+begin_src oil +const author = { + "name": "John Doe", + "birthdate": "1992-04-04", + "portfolio": [ + { "title": "Philistine: A Jon Doe story", "isbn": "392-423-2113-123" }, + { "title": "Whoa there!", "isbn": "241-123-35241-123" } + ] + "has_criminal_record": false +} + +write -- $[author['name']] $[author['portfolio'][0]['title']] +#+end_src + +Oil has a built-in JSON support with the =json= keyword. + +#+begin_src oil :shebang "#!/usr/bin/env oil" +const author = { + "name": "John Doe", + "birthdate": "1992-04-04", + "portfolio": [ + { "title": "Philistine: A Jon Doe story", "isbn": "392-423-2113-123" }, + { "title": "Whoa there!", "isbn": "241-123-35241-123" } + ] + "has_criminal_record": false +} + +json write :author +#+end_src + +This is handy as most tools has an option to print JSON data — e.g., =systemctl=, Ripgrep, =buku=, [[id:8135ece9-0dc0-4799-ac63-a24f9486ddd2][BorgBackup]]. + + + + * Tips and tricks - Oil seems to evaluate in applicative order, evaluating only when the conditions passed — e.g., ~echo $['' + null if null else 'EEEEHHH']~ should print =EEEEHHH=. diff --git a/structured/text.lilypond.org b/structured/text.lilypond.org index c7ebca0..b09c183 100644 --- a/structured/text.lilypond.org +++ b/structured/text.lilypond.org @@ -1,6 +1,6 @@ #+title: Lilypond #+date: "2021-05-10 19:36:43 +08:00" -#+date_modified: "2021-05-21 18:23:00 +08:00" +#+date_modified: "2021-07-11 08:39:53 +08:00" #+language: en #+property: header-args:lilypond :exports both @@ -36,7 +36,7 @@ The input file is a plain-text file making it very good with version control sys * Paper configuration #+name: lilypond-paper -#+begin_src lilypond :exports none +#+begin_src lilypond :exports code \paper { indent=10\mm oddFooterMarkup=##f