Update various notes on things

Still cannot make up a good note-taking habit especially that I archive
more than taking notes. Though, this same cannot be said for my course
notes so that's a plus.
This commit is contained in:
Gabriel Arazas 2022-05-22 22:47:20 +08:00
parent 8c378fc029
commit a5b3c7a8a1
19 changed files with 415 additions and 66 deletions

View File

@ -3,7 +3,7 @@
:END:
#+title: Create roadmaps to stay on track
#+date: "2021-04-30 14:12:52 +08:00"
#+date_modified: "2021-06-17 10:42:02 +08:00"
#+date_modified: "2022-05-22 22:32:08 +08:00"
#+language: en
@ -11,8 +11,8 @@ The internet is a place full of information.
In fact, too full.
You could consume endless information from one resource to another and create stagnation because you're adapting too many ideas at a time.
It could further your hoarding tendencies and maybe just start collecting knowledge.
[[id:6b0e6b75-410f-42a3-8921-bcc4589b2d2a][Collecting information only feels like progress]].
[[id:98625da4-8e40-4b3c-bd3e-65781ae1d76f][Time spent on learning a skill should equally spend time for applying said skill]].
It could further your hoarding tendencies and maybe just start collecting knowledge as [[id:6b0e6b75-410f-42a3-8921-bcc4589b2d2a][Collecting information only feels like progress]].
Having a roadmap helps you to stay on track whether you're studying for a job, creating a new project, or learning a new hobby.
This roadmap could be just a simple to-do list, an elaborate plan, or a one-line description of the output you expect [fn:: This is still a terrible example but it should eventually evolve into details.].

View File

@ -3,15 +3,43 @@
:END:
#+title: Look for live sessions as another form of examples
#+date: "2021-05-05 19:43:14 +08:00"
#+date_modified: "2021-10-27 16:41:42 +08:00"
#+date_modified: "2022-04-19 20:36:26 +08:00"
#+language: en
There is something powerful in seeing others doing the task as you are now seeing the process in action.
A possible reason is our human tendency to follow by example.
This is why apprenticeships are a popular form of this as you can gain an upclose look of how an experienced person does things.
Watching live sessions in any form can be a good way to learn and gain perspectives as you're viewing the raw footage of the task from its conception to its completion.
This is why seeing live sessions such as live studying, live coding, and speedpainting sessions are compelling to watch.
Some plausible real-life examples...
- In [[id:4b33103b-7f64-4b51-8f03-cac06d4001bb][Programming]], you may have discovered alternative ways to debug or introduce you to new tools that is very relevant to you.
- In [[id:cd7e8120-6953-44a6-9004-111f86ac52dc][Illustration]], you may see new approaches from drawing anatomies or quickly bootstrap a scenario.
- In roam:Speedrunning, you can see optimal routes and tricks that you may not know compared to your runs.
Even pre-rendered forms of live sessions such as documentaries, pre-recorded competition matches, behind-the-scenes footage, and commentaries are great to look for albeit incomplete.
It still gives you an idea of the process behind the topic.
This approach, as much as it is nice for gaining new perspectives, is not without its problems:
- You cannot easily see nuances with their approaches if it has subtleties.
This could may or may not affect their effectiveness.
- Seeing someone does something requires some prerequisite understanding of their domain.
It isn't exactly [[id:af0ccefe-c671-47bf-94f7-62243c805745][Skill-building]] without prerequisites.
- There is always a possibility of not taking away anything other than watching a person do something.
This could be due to different factors: e.g., you may have missed the subtle tendencies, you didn't have any idea at all what it is about (though, it can be nice sometimes; see [[id:0e2c9eaf-f12a-47b2-9c9c-d1a590db131b][Involuntary attention switch is good for preventing tunnel vision]]), you are already familiar with their domains.
As finicky this approach can be, this issue along with the previously mentioned ones can really just discourage into making you think you've just wasted time.
This approach will also be filled with questions as you pick up nuances and curiosities.
Therefore, this approach is nice along with [[id:6f9c552f-055b-4238-874e-8608006ce0ca][Communicate with others to learn]].
At the very least, looking for others' approaches can always show you cool new stuff.
But how about looking at live sessions of yourself?
(See [[id:806bf416-78fa-4136-8329-9d2c9da12485][Live sessions of yourself doing things as an example]].)

View File

@ -3,7 +3,7 @@
:END:
#+title: Understanding comes first from memory
#+date: "2021-05-14 11:48:20 +08:00"
#+date_modified: "2021-07-11 20:15:07 +08:00"
#+date_modified: "2022-05-22 22:41:10 +08:00"
#+language: en
@ -14,15 +14,17 @@ it is rooted from an experience of bad teaching thus we associate memorizing a b
Knowing the related things — or memorizing a bunch of facts — is a good way to start learning a concept.
With those things in mind, you can then combine the ideas, [[id:1e135aee-0464-4756-9f55-bbf12afe8254][Chunking]] them, and innovate new ones.
You cannot build upon more ideas if you don't know what those ideas are.
You cannot build upon more ideas if you don't know what those ideas are in the first place.
- You cannot know how to read and write traditional music notation if you don't want to memorize the order of the notes or the meaning of various symbols.
You can't put your finger why Undertale's music ties altogether with familiarity in its entire soundtrack or why [[https://www.youtube.com/watch?v=SdDeufxfJeE][Baka Mitai sounds very good]].
- Don't expect to have a good time comprehending derivatives if you don't know how to get the missing values from a system of equations or don't know what is a function.
- You cannot know what makes a good film if you cannot bother with the basics of 180 rule and solely focusing on understanding film techniques and comparing them from other films.
From personal experience, I used to not like this rote method of learning.
After some reflection, I think I got the reason: lack of understanding especially with the basics.
Remember that [[id:114b7874-6a20-49c8-be2c-46970c7110dc][Information is only acquired when you try to make sense of it]].
The problem could be the lack of time understanding it.
For practice, you can start with simple solutions like [[id:063dfd73-dbf5-437b-b6f1-d7aeca196f31][Spaced repetition]].
For one solution, see how my perspective on [[id:af0ccefe-c671-47bf-94f7-62243c805745][Skill-building]].

View File

@ -3,11 +3,13 @@
:END:
#+title: Skill-building
#+date: "2021-07-09 19:20:50 +08:00"
#+date_modified: "2021-08-07 19:53:52 +08:00"
#+date_modified: "2022-05-22 22:32:39 +08:00"
#+language: en
- [[id:92a10fe2-f4d1-4e5e-b5f4-3779db13a2e5][Create roadmaps to stay on track]] as a way to plan ahead.
- It is important to know that not all time should be spent on this.
[[id:98625da4-8e40-4b3c-bd3e-65781ae1d76f][Time spent on learning a skill should equally spend time for applying said skill]].
- [[id:1a6187c9-6c79-4378-bf8d-935c8a3d9167][Learning a new skill often starts from specific places]].
- [[id:f2012707-1220-4bf4-8e42-f558f19ca178][Learn with the materials intended for kids]] as a starting place.
- [[id:0dbfee88-cdce-48d1-9a10-23fc12d9bcd5][Refer to advanced resources when skill-building for a solid short-term goal]].

View File

@ -3,15 +3,15 @@
:END:
#+title: Examples and stories are more memorable than explanations
#+date: 2021-07-21 17:59:19 +08:00
#+date_modified: 2022-01-09 11:25:08 +08:00
#+date_modified: 2022-04-19 20:15:03 +08:00
#+language: en
- [[id:9f1f35dd-7cf9-4f47-a9a9-b647e5daa2af][We are more associative than structured]];
we easily weave a narrative on top of an idea or remember more easily because of a story
we easily weave a narrative on top of an idea or remember more easily because of a story;
examples and stories are just one compact idea that tend to tune more into familiar things (e.g., narratives, analogies)
- in my experience, legends and origin stories are often more memorable especially with the outlandish ones like the ancient Greek and Egyptian stories
- in a way, we [[id:9a11ef31-b2a7-43a9-a7a9-48f191838c6e][Prefer referencing over remembering]]
- examples and stories are just one compact idea that tend to tune more into familiar things (e.g., narratives, analogies)
- at times, we are also more creative than logical but it does not mean that [[id:2b2a4c85-905a-478c-9e2c-2a64d08e4785][Creativity and logic are not opposites]]
- obviously, this doesn't mean explanations should be abandoned;
[[id:c0e4fb0e-68f2-4db4-8c3e-f5a7845738c3][Understanding comes first from memory]] and explanations tend to be one of the first things we remember when going back to a topic

View File

@ -0,0 +1,33 @@
:PROPERTIES:
:ID: 788f57d1-86de-4ddd-81f5-f4680b04b0ea
:END:
#+title: Learn how to forget
#+date: 2022-05-20 21:48:41 +08:00
#+date_modified: 2022-05-20 22:06:46 +08:00
#+language: en
As a popular saying goes:
#+begin_quote
Empty the cup so that it may filled.
Become devoid to gain totality.
#+end_quote
Forgetting is often looked at a negative view but it can be used in a good way.
Accumulation of knowledge is not often a good thing.
There are various [[id:9dc7cb08-3aea-4f66-80ac-49a14b4b7642][Pitfalls and illusions of competence]] and situations where one can make a better judgement since [[id:60361cab-d006-4572-a7b2-e9dc7e1bc4da][Being misinformed is better than being ignorant]] (sometimes).
A good reason to learn about forgetting is [[id:5c603e2c-4dae-465e-abb5-12897ad7466d][Tunnel vision]].
Its tendency to block out new ideas in the way of solving a problem is certainly not a great situation to be in.
The solution can be simple: don't think about your initial solution.
In other words, forget it.
It can thought of as forcing yourself to see things in a (hopefully) new perspective.
Basically, the idea of [[id:2667d942-48b6-4d1e-b92b-15c2dab645ed][Switching between different topics makes new perspective]].
As much as this idea sounds unique, it completely isn't.
This idea is already made its way through all of our lives.
- Taking a break whenever we're stumped at a problem.
- [[id:063dfd73-dbf5-437b-b6f1-d7aeca196f31][Spaced repetition]] is a minor example of this.

View File

@ -0,0 +1,18 @@
:PROPERTIES:
:ID: 806bf416-78fa-4136-8329-9d2c9da12485
:END:
#+title: Live sessions of yourself doing things as an example
#+date: 2022-05-21 08:08:45 +08:00
#+date_modified: 2022-05-21 08:09:11 +08:00
#+language: en
- [[id:fdf9e3eb-02c5-47a6-b586-e71a5c92d01a][Look for live sessions as another form of examples]] mainly concerns with others doing it, how about a live session for yourself?
- unlike looking at others' live sessions, learning new approaches and perspectives is not the goal;
rather, it is to see flaws in our doing since we're busy focusing on doing the task
- we can use our tendency to be self-critical here especially now that examples are right in our faces
- examples
- live session of yourself doing [[id:cd7e8120-6953-44a6-9004-111f86ac52dc][Illustration]];
you can see your mistakes clearly and what you could've done better
- doing a recording of yourself [[id:4b33103b-7f64-4b51-8f03-cac06d4001bb][Programming]] your project
- recording a live session doing [[roam:Music composition]]

View File

@ -0,0 +1,32 @@
:PROPERTIES:
:ID: 98625da4-8e40-4b3c-bd3e-65781ae1d76f
:END:
#+title: Time spent on learning a skill should equally spend time for applying said skill
#+date: 2022-05-22 22:31:28 +08:00
#+date_modified: 2022-05-22 22:31:43 +08:00
#+language: en
- as drawn from the [[id:f7d03d2e-53b5-4b1c-8b97-2cc07c4272fe][Drawabox course]], there should be time spent on actually applying said skill for your own purposes;
in the end, [[id:7382c605-b481-4baa-997a-317f6cb1819c][Self-learning is about responsibility]];
you may as well throw the whole progress if you don't soak time for doing said skill
- technical knowledge isn't going to your future practical applications any better;
the act of applying said knowledge is a skill itself
- while you may have the technical knowledge of [[id:cd7e8120-6953-44a6-9004-111f86ac52dc][Illustration]], if you cannot draw the things that truly matters then it isn't truly progress
- while you have taken several online courses about [[id:4b33103b-7f64-4b51-8f03-cac06d4001bb][Programming]], if you don't have an actual project to work on (whether it is to scratch your own itch or contribute in other projects) for whatever reason then it is ultimately useless
- that is basically applying for biology major in college and only stopping at the actual knowledge
- basically, the idea of balancing time on work versus play
- obstacles
- out of fear and judgement;
the fear of embarrassing ourselves to the wider audience if mistakes are shown;
the worst case scenario is people will simply ignore it;
simply put, no one truly cares;
while it is important to [[id:6f9c552f-055b-4238-874e-8608006ce0ca][Communicate with others to learn]], you should also put up to reduce that tendency of self-critical and let go of that judgement
- [[id:0bb464a1-94c4-4130-bc7d-413465aea8e8][Procrastination]] is also one but not of the typical variety;
most people would see a thing for future projects and evaluate it as something that they cannot do in the current level until they can reach their desired skill level;
there is one more problem to this approach: we cannot simply know;
not only this can turn into a situation where [[id:03cd9fad-e187-4939-9347-1a034c6efbe2][Overanalyzing slow you down]], we'll eventually realize that [[id:864a9242-eb10-44ad-81b7-c237276523e5][We know more compared to what we understood]];
thus, the potential start for procastination will begin;
to mitigate this problem, the solution is simple: just start;
pursue the said too-advanced-for-me-type of project and use it as your jumpboard for starting out;
[[id:12dc8b07-ed8b-46d8-bff0-a38d9f3cb83b][Diving head-first with a difficult problem is a good indicator of progress]]

View File

@ -0,0 +1,21 @@
:PROPERTIES:
:ID: c278f8ce-32c1-4df4-8b91-e0325eb37778
:END:
#+title: Clash of Clans art style
#+date: 2022-05-21 08:22:57 +08:00
#+date_modified: 2022-05-21 09:06:54 +08:00
#+language: en
- the overall [[id:e527e948-911f-4719-8cd4-8b9dac7e6318][Supercell games art style]] is already great but we'll inspect one of their games extensively with Clash of Clans
- just like most of their games, Clash of Clans mainly features a semi-blocky cartoonish art style with a realistic 3D model
- all of their models are a nice of example of simple but great with subtle details on their units;
this can be seen in their environments: terrain, models, units, and buildings;
it's what made them to be individuals despite there can be multiple of them;
furthermore, this whats makes them easy to remember and memorable
- most (if not all) objects in the game have this hand-crafted feel to them;
this could be seen when inspected closely with the [[https://raw.githubusercontent.com/Statscell/clash-assets/main/troops/models/Barbarian.png][barbarian's]] chipped sword or the [[https://raw.githubusercontent.com/Statscell/clash-assets/main/troops/models/Wall_Wrecker.png][wall wrecker]] being a siege machine with the wooden texture and metallic accents
- combine this with their cartoonish art style, it is very nice to look at
- the art style in the rendered image begins to pop out even more in [[https://www.youtube.com/watch?v=ZdOkHJjLP2Q][their]] [[https://www.youtube.com/watch?v=g8S-Ee-TZzc][videos]]
- though, the same cannot be said for the in-game sprites for units are due to how the game uses them;
they still need to be recognizable but it will have multiple instances of them;

View File

@ -0,0 +1,24 @@
:PROPERTIES:
:ID: 360f59a5-d18b-49d6-8213-062ba4bfea7e
:END:
#+title: Monster Hunter art style
#+date: 2022-05-21 08:14:14 +08:00
#+date_modified: 2022-05-21 08:48:54 +08:00
#+language: en
- this only applies to the mainline games and spin-offs that are very similar to it
- [[roam:Monster Hunter]] mainly drawn in 3D roam:Anime style, akin to 3D [[roam:Phantasy Star]] games
- the mantra of this series is an alternate universe with a grounded take on monster designs;
the monsters have a realistic and grounded take on their designs mostly inspired from real-life fauna;
all of their designs relate to their abilities and how they interact with their usual environments
- Ukanlos is a monster mainly found in icelands;
featuring a jaw shovelling through the snow;
its body structure also enables it to swim through the snow
- Tigrex is a great and simple example;
a combination of tyrannosaurus rex and a tiger mainly hunting with violent persistence alone
- Nargacuga is a monster similar to Tigrex except with a jet-black hide, bladed wings, and a spiked tail intended for quick and silent hunting;
it is another example of simple and great grounded design
- even in other installments like Monster Hunter: Rise with the presentation of the world as magical, the monsters within it still has a grounded take;
- even in older games, there is a level of realism and can be seen up close from their 3D models;
it is pretty fantastic to see that kind of detail :)

View File

@ -3,13 +3,14 @@
:END:
#+title: Supercell games art style
#+date: 2021-08-07 13:43:47 +08:00
#+date_modified: 2021-08-07 13:45:15 +08:00
#+date_modified: 2022-05-21 09:13:51 +08:00
#+language: en
- There's a lot of graphics design inspiration to be had from their games from Clash of Clans, Brawl Stars, Clash Quest, and even Hay Day.
- Most of them are pretty simple to look at but very stylistic.
This could be seen directly from [[https://supercell.com/en/for-media/][their media page]].
- A lot of them is a good starting point for art (e.g., illustration, 3D modelling).
- This is especially true for their recent games especially the spin-offs from established universes (e.g., Clash Quest, Clash Mini).
They designed it to look different but completely familiar with their gameplay and associated tropes.

View File

@ -3,7 +3,7 @@
:END:
#+title: Neovim Lua integration
#+date: "2021-07-15 07:45:50 +08:00"
#+date_modified: "2022-04-20 18:49:17 +08:00"
#+date_modified: "2022-04-20 21:19:43 +08:00"
#+language: en
@ -12,26 +12,50 @@
it gives all of the information on the things you need to get started with configuring Neovim with Lua as well as pointers for more things to do with Lua;
- Neovim also extends the Lua standard library found in =vim= object;
see the =lua-stdlib= in [[id:0a0fe63e-dcf3-4928-9e82-5513784c1244][Neovim help system]]
- 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
* Setting configuration with Lua
- you can still execute Vimscript with =vim.cmd=;
more information is at =:h lua-vimscript=
- 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"~
- interacting with Neovim API through =vim.api=
There are some equivalent setting values in Lua versus Vimscript.
For more information, see the =lua-vimscript= help section.
| Description | Vimscript statement | Lua equivalent |
|---------------------------------+-----------------------------+-------------------------------------------------------|
| Setting options | ~set number relativenumber~ | ~vim.opt.number, vim.opt.relativenumber = true, true~ |
| Setting local options | ~setlocal spell~ | ~vim.opt_local.spell = true~ |
| Running Vimscript commands | ~colorscheme nord~ | ~vim.cmd "colorscheme nord"~ |
| Setting buffer-specific options | ~b:ale-enabled=1~ | ~vim.b["ale-enabled"] = 1~ |
Some more general things you generally want to know:
- You can still execute Vimscript with =vim.cmd=.
For more information, see =:h lua-vimscript= from the help system.
- You can access environment variables through =vim.env= — e.g., ~vim.env.HOME~, ~vim.env.MYVIMRC~.
- Highlight options are mostly in =vim.highlight= — e.g., ~highlight clear SpellCap~ versus ~vim.highlight~.
- You can manipulate variables of various scopes 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.
* Real-life examples making use of Neovim Lua API
This is a list of [[id:bdcff35e-15e1-4539-9c4e-5fdd5b978c26][Neovim Lua modules]] that can serve as a basis for learning to interact Neovim with 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
Several people have already replaced their already existing Vim configurations with Neovim.
- TJ DeVries' [[https://github.com/tjdevries/config_manager/][Neovim config]] is fully written in Lua complete with his own plugins.
- ThePrimeagen's [[https://github.com/ThePrimeagen/.dotfiles/][public dotfiles]] contains Neovim config written in Lua.

View File

@ -0,0 +1,159 @@
:PROPERTIES:
:ID: 61949403-45c1-495f-818e-01229d304dbb
:END:
#+title: Neovim plugin: LuaSnip
#+date: 2022-04-21 15:33:29 +08:00
#+date_modified: 2022-04-21 16:41:42 +08:00
#+language: en
#+property: header-args :eval no
- manual from [[id:0a0fe63e-dcf3-4928-9e82-5513784c1244][Neovim help system]]: =luasnip.txt=
- snippets are made of nodes
- there are different type of nodes;
these can be found on the =luasnip-snippets= on the manual
- *text nodes* are just static text
- *insert nodes* are points to be edited;
can be given default text for the snippet
- *function nodes* generate text based from other nodes;
this is used mostly to generate dynamic output from the snippet
- *choice nodes* contains multiple nodes to be chosen for a given jump position
- *snippet nodes* contains other node to be inserted in the snippet
- *dynamic nodes* are similar to function nodes except they return snippet nodes
- LuaSnip can support several types of snippets other than its own
- SnipMate snippets
- Visual Studio Code snippets
- Lua snippets, obviously
- snippets are not automatically loaded unless you have invoked the appropriate function for a certain type;
you will not load Visual Studio Code-style snippets unless you have run =lazy_load= function from =luasnip.loaders.from_vscode=;
for more details, each supported format has a specific section for loading them from the manual (e.g., =luasnip-vscode-snippets-loader=)
- adding snippets is as simple as adding them in =require("luasnip").snippets.FILETYPE=;
though, you have to know how to add a snippet through LuaSnip module
* Example snippets in Lua
We'll explore different examples from the simplest to the more complex snippets made with Lua.
The following code blocks will assume the environment with the default value from =luasnip.config.snip_env=.
The plugin source code also has a comprehensive set of examples in the =Examples/= folder.
It also has a [[https://github.com/L3MON4D3/LuaSnip/wiki][wiki]] containing multiple example snippets showcasing the various nodes.
** Simple word trigger
The simplest snippet possible.
This will simply replace =hello= with =world=.
#+begin_src lua
s("hello", t "world")
#+end_src
Exploring other nodes, we could replace the text node with a function node.
#+begin_src lua
s("hello", f(function ()
return "world"
end))
#+end_src
** Patterned trigger
A simple snippet that will answer you back when triggered.
This snippet makes use of:
- Pattern triggers (see [[roam:Lua patterns]]).
- Snippet captures similar to UltiSnips' capture.
- Usage of a function node.
#+begin_src lua
s(
{ trig = "hello (%a+)", regTrig = true },
f(function (_, snip)
return string.format("hey there, %s", snip.captures[1])
end)
)
#+end_src
** Choosing between Asciidoctor admonition blocks
We can easily create a snippet for multiple choices.
In Asciidoctor, we have [[https://docs.asciidoctor.org/asciidoc/latest/blocks/admonitions/][admonition blocks]] that are formatted similarly.
Here's one way to define such snippet...
#+begin_src lua
s(
"admo",
fmt([[
{}: {}
]], {
c(1, {
t "NOTE",
t "TIP",
t "IMPORTANT",
t "CAUTION",
t "WARNING",
}),
i(0),
})
)
#+end_src
** Dynamic Asciidoctor header with optional automatic TOC
Here is a snippet for Asciidoc documents for creating headers.
As an example, =h6= should print the appropriate header level.
It should follow some restrictions for this snippet.
- It can only have a maximum level of 6.
- As a bonus, we could set the table of contents on if the header level is 1.
This snippet makes use of dynamic node to change the node between a choice node for the first heading level and a blank text node for the rest.
#+begin_src lua
function min_asciidoc_header_level(level)
math.min(level, 6)
end
s(
{ trig = "h(%d)", regTrig = true },
fmt([[
{} {}
{}
{}
]], {
f(function(_, snip)
local level = min_asciidoc_header(snip.captures[1])
return string.rep("=", level)
end),
i(1, "CHAPTER"),
d(2, function(_, snip)
local nodes = {}
table.insert(nodes, t "")
local level = min_asciidoc_header(snip.captures[1])
if level == 1 then
table.insert(nodes, t ":toc:")
end
local parent = c(1, nodes)
if level > 1 then
parent = t ""
end
return sn(nil, parent)
end, {}),
i(0),
})
)
#+end_src

View File

@ -3,25 +3,26 @@
:END:
#+title: Neovim text objects
#+date: 2022-04-01 16:06:02 +08:00
#+date_modified: 2022-04-02 19:35:33 +08:00
#+date_modified: 2022-05-22 22:46:31 +08:00
#+language: en
(Neo)Vim has a bunch of text objects that are beyond simple boundaries other than a word (~aw~, ~aW~).
You can find more of them with ~text-objects~ section from [[id:0a0fe63e-dcf3-4928-9e82-5513784c1244][Neovim help system]].
(Neo)Vim has a bunch of text objects that are beyond simple boundaries other than a word (=aw=, =aW=).
You can find more of them with =text-objects= section from [[id:0a0fe63e-dcf3-4928-9e82-5513784c1244][Neovim help system]].
| Text object | Description |
|-------------+---------------------------------|
| ~ap~ | A paragraph, equivalent to ~}~. |
| ~as~ | A sentence, equivalent to ~)~. |
| ~ab~ | A '( )' block. |
| ~aB~ | A '{ }' block. |
| Text object | Description |
|-------------+-------------------------------------|
| =ap= | A paragraph, equivalent to =}=. |
| =as= | A sentence, equivalent to =)=. |
| =ab= | A '( )' block. |
| =aB= | A '{ }' block. |
| =a"= | Content inside double-quotes (="=). |
There is also a variation for selecting only the inner content of the previous text objects (e.g., ~ip~ for the inner paragraph, ~is~ for inner sentence) with the whitespace removed.
There is also a variation for selecting only the inner content of the previous text objects (e.g., =ip= for the inner paragraph, =is= for inner sentence) with the whitespace removed.
Note that selecting with text objects is different from selecting with [[roam:Neovim motions]] where it refers to the current position up to the end of the next selection.
Meanwhile, text objects selection will select to the referred object as a whole no matter where the cursor position.
For example, selecting with the paragraph (i.e., ~vap~) will select the whole paragraph where the cursor rests.
For example, selecting with the paragraph (i.e., =vap=) will select the whole paragraph where the cursor rests.
Aside from the built-in text objects, you can create your own.
Which also means others have created some custom text objects.

View File

@ -3,7 +3,7 @@
:END:
#+title: Tunnel vision
#+date: "2021-07-15 22:21:04 +08:00"
#+date_modified: "2021-08-07 11:35:53 +08:00"
#+date_modified: "2022-05-20 21:56:28 +08:00"
#+language: en
@ -12,7 +12,7 @@
it is a net negative if we force our way with the familiar solution while not understanding the new type of problem
- [[id:9f1f35dd-7cf9-4f47-a9a9-b647e5daa2af][We are more associative than structured]];
we tend to create connections between different things including new things;
- we may also have to [[roam:Learn how to forget]];
- we may also have to [[id:788f57d1-86de-4ddd-81f5-f4680b04b0ea][Learn how to forget]];
in a world of quick and constant changes, learning new rules and topics takes up mental resources;
we have to assign some garbage day at some point;
unfortunately, we cannot easily do that from our experience as we try to survive by sticking to what we know

View File

@ -3,7 +3,7 @@
:END:
#+title: systemd-boot
#+date: 2021-08-07 20:08:09 +08:00
#+date_modified: 2021-08-07 20:08:31 +08:00
#+date_modified: 2022-05-22 21:24:33 +08:00
#+language: en
@ -51,7 +51,7 @@ options root="PARTUUID=${PARTUUID}"
#+end_src
You can customize and create extra entries for the same installation.
This is what roam:NixOS does with its package generations, letting the user to boot to a specific point in time from the boot loader.
This is what [[id:7e8e83d5-4b08-44f6-800d-a322f6960a62][NixOS]] does with its system generations, letting the user to boot to a specific point in time from the boot loader.
Very useful for emergency boots in case the current generation breaks for whatever reason.
For complete details of the configuration file, you can see =loader.conf.5= manual page.

View File

@ -3,7 +3,7 @@
:END:
#+title: systemd timers
#+date: 2021-07-19 21:45:47 +08:00
#+date_modified: 2022-04-16 19:37:37 +08:00
#+date_modified: 2022-05-22 22:28:49 +08:00
#+language: en
@ -56,7 +56,7 @@ WantedBy=graphical.target
#+end_src
If the timer unit is started, this will trigger =borg-backup.service= from the load path.
But you can omit it if you named the timer unit file similarly (e.g., =borg-backup.timer= with =borg-backup.service=).
But you can omit =Timer.Unit= key if you named the timer unit file similarly (e.g., =borg-backup.timer= with =borg-backup.service=).
You can find more information about it from the =systemd.timer.5= manual page.
Furthermore, systemd has a testing tool for time with ~systemd-analyze {timespan,timestamp,calendar}~.
@ -93,16 +93,16 @@ Timestamp example:
Normalized form: Thu 2021-07-01 00:00:00 PST
(in UTC): Wed 2021-06-30 16:00:00 UTC
UNIX seconds: @1625068800
From now: 11h ago
From now: 10 months 21 days ago
..............
Calendar example:
..............
Original form: *-1/4-5 0/2:00:00
Normalized form: *-01/4-05 00/2:00:00
Next elapse: Sun 2021-09-05 00:00:00 PST
(in UTC): Sat 2021-09-04 16:00:00 UTC
From now: 2 months 4 days left
Next elapse: Mon 2022-09-05 00:00:00 PST
(in UTC): Sun 2022-09-04 16:00:00 UTC
From now: 3 months 13 days left
..............
#+end_example

View File

@ -3,7 +3,7 @@
:END:
#+title: systemd unit hardening
#+date: 2022-04-19 20:19:26 +08:00
#+date_modified: 2022-04-19 20:21:27 +08:00
#+date_modified: 2022-04-22 18:10:16 +08:00
#+language: en
@ -14,19 +14,23 @@
- the only unit possible to attain the lowest score is a simple "Hello world" program or similar so don't go for a 1.0
- several systemd unit options are only available in certain units such as system services
- here is a list of sandboxing-related options;
for more information, see ~systemd.exec.5~ manual page
- ~ProtectHome~ will restrict process to interact with ~/home~, ~/root~, and ~/run/user~;
can accept a boolean or certain values: ~read-only~ will set certain directories to read-only and ~tmpfs~ will mount the temporary filesystems to the directories as read-only;
- ~ProtectControlGroups~ will make the control group filesystem (i.e., ~/sys/fs/cgroup~) to read-only
- ~PrivateUsers~, if enabled, will run the processes through another user
- ~ProtectClock~ prohibits interacting with the system clock
- ~ProtectKernelModules~ restricts loading of kernel modules
- ~ProtectKernelLogs~ prevents logging into the kernel ring buffer
- ~PrivateTmp~ will create a new temporary filesystem for the unit
- ~PrivateNetwork~ will create a new set of network devices only composing of a loopback network device;
for more information, see =systemd.exec.5= manual page
- =ProtectHome= will restrict process to interact with =/home=, =/root=, and =/run/user=;
can accept a boolean or certain values: =read-only= will set certain directories to read-only and =tmpfs= will mount the temporary filesystems to the directories as read-only;
- =ProtectControlGroups= will make the control group filesystem (i.e., =/sys/fs/cgroup=) to read-only
- =PrivateUsers=, if enabled, will run the processes through another user
- =ProtectClock= prohibits interacting with the system clock
- =ProtectKernelModules= restricts loading of kernel modules
- =ProtectKernelLogs= prevents logging into the kernel ring buffer
- =PrivateTmp= will create a new temporary filesystem for the unit
- =PrivateNetwork= will create a new set of network devices only composing of a loopback network device;
this will disallow network access and thus should only use for processes with no business with network access
- ~PrivateDevices~ will create a new set of devices with only the pseudo-devices (e.g., ~/dev/null~, ~/dev/zero~);
- =PrivateDevices= will create a new set of devices with only the pseudo-devices (e.g., =/dev/null=, =/dev/zero=);
this will restrict device access and should be used for processes with no device access
- =SystemCallFilter= takes a space-separated list of system calls to be filtered to the unit;
if the unit is detected to call one of the listed syscall, systemd will terminate them;
while listing them individually is possible, systemd has predefined set of calls putting them into categories;
to see them, use ~systemd-analyze syscall-filters~
- extra resources
- [[https://www.ctrl.blog/entry/systemd-service-hardening.html][systemd service hardening]] from ctrl.blog
- also, a [[https://www.ctrl.blog/entry/systemd-opensmtpd-hardening.html][follow-up post that uses a real-life example for service hardening a web server with recent exploits]]

View File

@ -3,7 +3,7 @@
:END:
#+title: Nix flakes
#+date: 2021-07-18 22:34:11 +08:00
#+date_modified: 2022-01-07 13:58:21 +08:00
#+date_modified: 2022-05-22 21:24:01 +08:00
#+language: en
@ -22,7 +22,7 @@ So, why use flakes?
- Since it is self-contained, it is easier to compose and develop environments for projects.
- It is more declarative compared to Nix channels.
- Provides a structure for discoverability through exploring the output.
- In case you're using roam:NixOS, it also provides an easier way to extend it with third-party custom modules.
- In case you're using [[id:7e8e83d5-4b08-44f6-800d-a322f6960a62][NixOS]], it also provides an easier way to extend it with third-party custom modules.