
诗者述事以寄情,事贵详,情贵隐,及乎感会于心,则情见于词,此所以入人深也。如将盛气直述,更无馀味,则感人也浅
Away From Keyboard | |||||
Home | About | Posts | Tags | Projects | RSS |
临汉隐居诗话 | Updated | ||
---|---|---|---|
Words | 103 | ||
Tags | Read | 1 minute |
诗者述事以寄情,事贵详,情贵隐,及乎感会于心,则情见于词,此所以入人深也。如将盛气直述,更无馀味,则感人也浅
the essence of Emacs | Updated | ||
---|---|---|---|
Words | 151 | ||
Tags | Read | 1 minute |
I’m quite fond of this saying—it captures the essence of Emacs perfectly.
The core idea of Emacs is to have an expressive digital material and an open-ended, user-extensible set of commands that manipulate that material and can be quickly invoked. Obviously, this model can be fruitfully applied to any digital material, not just plain text.
Use specific SSH keys | Updated | ||
---|---|---|---|
Words | 141 | ||
Tags | Read | 1 minute |
Multiple SSH keys for different github accounts · GitHub
How to use specific ssh key for different GitHub accounts, this is the best and simple solution
.git/config
[core]
sshCommand = ssh -i ~/.ssh/id_first_key
Doom emacs re-download package | Updated | ||
---|---|---|---|
Words | 190 | ||
Tags | Read | 1 minute |
If you are experiencing issues with a Doom Emacs package that has been cloned from GitHub, and you want to force a re-download or re-clone of the package, you can use the following steps to address the issue:
rm -rf ~/.emacs.d/.local/straight/repos/<package-name>
Replace
rm -rf ~/.emacs.d/.local/straight/build/<package-name>
doom sync
Remember that you should re-enable the package your config.el before running doom sync if you previously disabled it.
System and User-Specific Package Installation Paths in nix-darwin | Updated | ||
---|---|---|---|
Words | 25 | ||
Tags | Read | 1 minute |
Packages defined with environment.systemPackages in nix-darwin are installed to /var/current-system/sw/bin
. Those configured with home-manager go to the user-specific profile’s bin directory, typically found at ~/.nix-profile/bin
.
Why Python list comprehension is efficient | Updated | ||
---|---|---|---|
Words | 138 | ||
Tags | Read | 1 minute |
THIS is Why List Comprehension is SO Efficient! - YouTube
Python list comprehension is faster than using the .append()
method in a loop because it utilizes a special LIST_APPEND bytecode, which is more efficient than the costly object method lookup.
Goto in C programming language | Updated | ||
---|---|---|---|
Words | 623 | ||
Tags | Read | 2 minutes |
I have very limited experience about goto statement except that I know it is not encouraged in high level language. Today I learn from a comment of
why is it illegal to use “goto”
that goto
statement are commonly used in Linux kernel in resource acquisition/release pattern.
The goto statement comes in handy when a function exits from multiple locations and some common work such as cleanup has to be done. If there is no cleanup needed then just return directly.
Centralized exiting of functions - Linux kernel coding style
Simplifies Error Handling
: When acquiring multiple resources, each step might fail. Normally, you’d need nested if statements to handle these failures. However, with goto, you can jump to the specific code that releases resources, simplifying the error handling.
Clarity and Maintenance
: By using goto for forward jumps, the flow of error handling becomes linear and more readable. This is in contrast to nested if statements, which can become complex and difficult to follow.
int function() {
int *resource1 = acquireResource1();
if (resource1 == NULL) goto error1;
int *resource2 = acquireResource2();
if (resource2 == NULL) goto error2;
// Use resources...
releaseResource2(resource2);
releaseResource1(resource1);
return SUCCESS;
error2:
releaseResource1(resource1);
error1:
return FAILURE;
}
In this example, if acquiring resource2 fails, the code jumps to error2, where resource1 is released. This ensures that even if there is an error in acquiring the second resource, the first one is properly released
what is retrieval augmented generation | Updated | ||
---|---|---|---|
Words | 719 | ||
Tags | Read | 3 minutes |
This video gives an easy explanation about RAG(retrieval augmented generation)
https://youtu.be/T-D1OfcDW1M?si=a_06Z9VkMSwuh6To
Here is my notes about RAG
The RAG technique was invented to enhance the accuracy and relevance of responses generated by LLMs. The key motivations for developing RAG were:
To Provide Up-to-Date Information
: By integrating a retrieval system, RAG ensures that the LLM has access to the most current information, thereby improving the accuracy of its responses.To Improve Fact-Checking Capabilities
: RAG allows LLMs to cross-reference information with reliable sources, enhancing their ability to verify facts and provide more trustworthy responses.To Address the Static Nature of LLMs
: Since LLMs are trained on static datasets, they can become outdated. RAG introduces a dynamic element where the model can access and incorporate new and updated information.The RAG framework works by combining the capabilities of a traditional LLM with an external information retrieval system. The process involves:
Retrieval of Relevant Information
: When a query is made, the RAG system first retrieves relevant information from an external data store. This data store is continuously updated with new information.Generation of Informed Responses
: The LLM uses both the retrieved information and its pre-existing knowledge base to generate a response. This ensures that the response is not only based on its training data but also on the most current information available.Continuous Updating
: The data store used for retrieval is continuously updated, allowing the LLM to stay current with new information and developments.Instruction
: This is a directive or guideline that tells the language model what kind of response is expected. It sets the context or the goal for the response.Retrieved Content
: This part includes the relevant information retrieved from a large-scale data store. This content is dynamically sourced based on the query, ensuring that the information is up-to-date and pertinent to the user’s question.User's Question
: This is the actual query or question posed by the user. It’s what the user wants to know or the problem they need solved.Here’s how the three-part prompt might looks like:
Use the following pieces of context to answer the question at the end.
If you don't know the answer, just say that you don't know, don't try to make up an answer.
Use three sentences maximum and keep the answer as concise as possible.
Always say "thanks for asking!" at the end of the answer.
<An article or a set of articles from a reputable source, retrieved by the system, discussing the latest developments in AI as of 2023.>
Question: "What are the latest advancements in artificial intelligence?"
refer langchain
Arbitrary HTML tags in Hugo | Updated | ||
---|---|---|---|
Words | 228 | ||
Tags | Read | 1 minute |
A nice way to add arbitrary HTML tags in Hugo site markdown content.
Create a content.html
in layouts/partials
{{
.
| replaceRE `\{\^([^}]*)\}` "<sup>$1</sup>"
| replaceRE `\{\_([^}]*)\}` "<sub>$1</sub>"
| replaceRE `\{\#([^}]*)\}` "<kbd>$1</kbd>"
| replaceRE `\{\!([^}]*)\}` "<mark>$1</mark>"
| replaceRE `\{\=([^}]*)\}` "<cite>$1</cite>"
| replaceRE `\{\+([^}]*)\}` "<ins>$1</ins>"
| replaceRE `\{\$([^}]*)\}` "<var>$1</var>"
| safeHTML
}}
and use the partial html template {{ partial "content.html" .Content }}
to render the HTML
Get missing inline HTML tags in Markdown without enabling HTML - tips & tricks - HUGO
Setup Development Environment for Macbook | Updated | ||
---|---|---|---|
Words | 2196 | ||
Tags | Read | 4 minutes |
System Settings > Accessibility > Display > Turn On Reduce Motion
⌘
change to ^
caps lock
change to ⌘
# show hidden files
defaults write com.apple.finder AppleShowAllFiles YES
# show path bar
defaults write com.apple.finder ShowPathbar -bool true
killall Finder;
brew install --cask \
qlcolorcode \
qlstephen \
qlmarkdown \
quicklook-json \
qlprettypatch \
quicklook-csv \
betterzip \
webpquicklook \
suspicious-package
brew install --cask \
appcleaner \
google-chrome \
iterm2 \
raycast \
visual-studio-code
# [Nerd Font](https://www.nerdfonts.com/)
brew install --cask font-fira-code-nerd-font
brew install \
bat \
fish \
git \
git-delta \
go \
hugo \
jq \
neofetch \
orbstack \
ripgrep \
starship \
tree \
wget
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.ss status
~/.gitconfig
[core]
pager = delta
[interactive]
diffFilter = delta --color-only
[delta]
navigate = true # use n and N to move between diff sections
light = false # set to true if you're in a terminal w/ a light background color (e.g. the default macOS terminal)
[merge]
conflictstyle = diff3
[diff]
colorMoved = default
starship preset nerd-font-symbols -o ~/.config/starship.toml
add to ~/.config/fish/config.fish
# Add HomeBrew's bin directory to path so you can use HomeBrew's binaries like `starship`
# Fish uses `fish_add_path` instead of `export PATH` modify $PATH.
fish_add_path "/opt/homebrew/bin/"
# Enable Starship prompt
starship init fish | source
plugin:
add to ~/.config/fish/config.fish
source ~/.config/fish/abbreviation.fish
create abbreviation.fish
abbr proxyall "set --export http_proxy http://127.0.0.1:7890; set --export https_proxy http://127.0.0.1:7890"
it’s very easy to add a custom function in fish shell, an example
Side Bar:Location change to right
use
pyenv
to manage Python environments, don’t reply on the python installed by brew
, because it might update Python version upexpecetdly when performs brew update
.
brew install readline xz pyenv
# otpinal: setup pyenv with fish shell
alias brew="env PATH=(string replace (pyenv root)/shims '' \"\$PATH\") brew"
exec "$SHELL"
pyenv install 3.11.6
pyenv global 3.11.6
iTerm2
Use fn
to Change Input Source
Keyboard Shortcuts -> Uncheck all Input Sources
Spotlight
Keyboard Shortcuts -> Modifier Keys
Caps Lock Key
-> Command
Command
-> Control
Keyboard Shortcuts -> keep Modifier Keys unchanged
Karabiner-Elements
fn
Make Caps Lock → Hyper Key (⌃⌥⇧⌘) (Caps Lock if alone) import
System Integrity Protection
)yabai installation and configuration reference:
skhd config
cmd + ctrl + shift + alt
is the Hyper
Key configurated using Karabiner-Elements
# change focus between external displays (left and right)
cmd + ctrl + shift + alt - p : yabai -m display --focus west
cmd + ctrl + shift + alt - n : yabai -m display --focus east
# fullscreen window
cmd + ctrl + shift + alt - m : yabai -m window --toggle zoom-fullscreen
# cycle focus between windows
cmd + ctrl + shift + alt - o : yabai -m window --focus prev || yabai -m window --focus last
# cycle swap window to the main window
cmd + ctrl + shift + alt - j : /bin/bash ~/bin/cycle_clockwise.sh; yabai -m window --focus prev || yabai -m window --focus last
# rotate layout clockwise
cmd + ctrl + shift + alt - r : yabai -m space --rotate 270
# flip along y-axis
cmd + ctrl + shift + alt - y : yabai -m space --mirror y-axis
# flip along x-axis cmd + ctrl + shift + alt - x : yabai -m space --mirror x-axis
# toggle window float
cmd + ctrl + shift + alt - f : yabai -m window --toggle float --grid 4:4:1:1:2:2
cycle_clockwise.sh
:
#!/bin/bash
win=$(yabai -m query --windows --window last | jq '.id')
while : ; do
yabai -m window $win --swap prev &> /dev/null
if [[ $? -eq 1 ]]; then
break
fi
done