Browse Categories All Posts
Categories
K
Kai
Post Timeline
This PC
Timeline
Recycle Bin
mac fonts

mac fonts

 cool free apple fonts

https://devimages-cdn.apple.com/design/resources/download/SF-Pro.dmg

https://devimages-cdn.apple.com/design/resources/download/SF-Compact.dmg

https://devimages-cdn.apple.com/design/resources/download/SF-Mono.dmg

https://devimages-cdn.apple.com/design/resources/download/NY.dmg

install 7zip

extractor.sh

TMP=$(mktemp -d)
mkdir font
7z e "$1" -o"$TMP" -bd -y &> /dev/null
7z e $TMP/"*.pkg" -o"$TMP" -bd -y &> /dev/null
find $TMP -name "Payload" -exec 7z e {} -bd -y &> /dev/null
7z e $TMP/Payload -o"$TMP" -bd -y  &> /dev/null
7z e $TMP/Payload~ -ofont -bd -y &> /dev/null
rm -rf $TMP &> /dev/null

bash  extractor.sh SF-Pro.dmg

 

gnu readline

gnu readline

 many cli apps use libreadline Bash, GDB, Python REPL, sqlite3 

Movement

Shortcut (Emacs)Action
Ctrl + aMove to the beginning of the line
Ctrl + eMove to the end of the line
Ctrl + fMove forward one character (equivalent to Right Arrow)
Ctrl + bMove backward one character (equivalent to Left Arrow)
Alt + fMove forward one word
Alt + bMove backward one word
Ctrl + x, Ctrl + xToggle cursor position between current location and start of line

Cutting, Deleting & Pasting (Yanking)

Shortcut (Emacs)Action
Ctrl + dDelete character under the cursor (or exit shell on empty line)
Backspace / Ctrl + hDelete character before the cursor
Alt + BackspaceDelete word before the cursor
Alt + dDelete word after the cursor
Ctrl + kCut (kill) text from cursor to end of line
Ctrl + uCut (kill) text from cursor to beginning of line
Ctrl + wCut (kill) previous whitespace-delimited word
Alt + \Delete all spaces/tabs around the cursor
Ctrl + yPaste (yank) top item from the kill ring
Alt + yCycle through previous items in the kill ring (after pressing Ctrl + y)

History Navigation

Shortcut (Emacs)Action
Ctrl + rIncremental backward search through command history
Ctrl + sIncremental forward search (may require stty -ixon to disable flow control)
Ctrl + pMove to previous history entry (Up Arrow)
Ctrl + nMove to next history entry (Down Arrow)
Alt + . or Alt + _Insert last argument of previous command
Alt + <Move to first entry in history
Alt + >Move to last entry in history

Completion & Macro Tricks

Shortcut (Emacs)Action
TabAutocomplete command/path
Alt + ?List possible completions without expanding
Alt + *Insert all possible completions directly onto the command line
Ctrl + lClear terminal screen (preserves current line input)
Ctrl + tTranspose (swap) character under cursor with preceding character
Alt + tTranspose (swap) word under cursor with preceding word
Alt + uUppercase word from cursor to end of word
Alt + lLowercase word from cursor to end of word
Alt + cCapitalize character at cursor and move to end of word
Ctrl + _ or Ctrl + x, Ctrl + uUndo last editing action

config

~/.inputrc

set completion-ignore-case on

set completion-map-case on 

set show-all-if-ambiguous on 

set colored-stats on 

set visible-stats on 

set completion-query-items 200 

set bell-style none 

set horizontal-scroll-mode off 

"\e[A": history-search-backward 

"\e[B": history-search-forward 


src

https://tiswww.case.edu/php/chet/readline/rltop.html


tmux

tmux

tmux = unammed session

tmux new -s <name>

tmux ls

tmux attach -t <name>

tmux a = attach to last used session

tmux kill-session -t <name>

tmux kill-server


inside tmux

prefix = Ctrl + b

prefix+d = detach from session ( keep running in bg)

prefix+$ = rename session

prefix+s = list all session interactive mode


tabs:

prefix+c — Create a new window

prefix+, — Rename the current window

prefix+n — Switch to next window

prefix+p — Switch to previous window


prefix+0-9 — Jump directly to window number N

prefix+w — Interactive visual list of windows/panes

prefix+& — Close current window (prompts for confirmation)


splits:

prefix+% — Split current pane vertically (left / right)

prefix+" — Split current pane horizontally (top / bottom)

prefix+Arrow Key — Move focus between panes

prefix+o — Cycle focus to the next pane

prefix+; — Toggle back to the last active pane

prefix+z — Toggle pane zoom (maximize current pane full screen / restore)

prefix+{ or } — Swap position of current pane with adjacent pane

prefix+x — Close current pane (prompts for confirmation)


copy,navigate

Press Ctrl + b then [ to enter copy mode.

Navigate using Arrow Keys, PageUp/PageDown, or Vim keys (h, j, k, l).

Press Space to start selecting text, Enter to copy the selected text to tmux buffer, and q to exit copy mode.

Press Ctrl + b then ] to paste the copied buffer.


cat ~/.tmux.conf

# Enable mouse mode (scrolling, clicking panes/tabs)

set -g mouse on

# Increase scrollback history limit

set -g history-limit 10000

# Start window/pane indexing at 1 instead of 0

set -g base-index 1

setw -g pane-base-index 1





AI Model Quantization

AI Model Quantization

 

What is AI Model Quantization?

AI model quantization is the process of reducing the precision of the numbers (weights and activations) that make up a neural network.

Normally, machine learning models are trained using 32-bit floating-point precision (FP32). Quantization maps these high-precision numbers to lower-bit representations (such as 16-bit, 8-bit, 4-bit, or even 2-bit integers or floats).

Why is it used?

  • Reduced Memory Footprint: A model's size shrinks almost proportionally to the drop in bit-width, allowing large language models (LLMs) to run on consumer hardware or edge devices.

  • Faster Inference: Lower-bit operations require less memory bandwidth and can be processed faster by modern hardware accelerators (like GPUs, TPUs, and NPUs).

  • Lower Energy Consumption: Moving less data around reduces power usage, which is crucial for mobile and embedded devices.

Breakdown of Bit Levels: 32-bit down to 2-bit

1. 32-bit Quantization (FP32 / INT32)

  • Precision: Full precision (the baseline for training). Each parameter takes 4 bytes of memory.

  • Use Case: Model training and scenarios where maximum accuracy is required, and memory/compute constraints do not exist.

  • Trade-off: High memory usage and slower inference speeds.

2. 16-bit Quantization (FP16 / BF16)

  • Precision: Half precision. Each parameter takes 2 bytes of memory.

  • Use Case: Standard for training modern LLMs and running inference on modern GPUs without noticeable loss in accuracy.

  • Trade-off: Cuts memory usage in half compared to FP32 with virtually zero degradation in model performance.

3. 8-bit Quantization (INT8)

  • Precision: Standard quantization level where weights are compressed to 1 byte.

  • Use Case: Highly popular for deploying models in production. Techniques like PTQ (Post-Training Quantization) and QAT (Quantization-Aware Training) make 8-bit models run efficiently on standard hardware.

  • Trade-off: Minimal to negligible accuracy loss while cutting memory requirements by 75% compared to FP32.

4. 4-bit Quantization (INT4 / NF4)

  • Precision: Extremely compressed, averaging 4 bits per parameter (often using formats like NormalFloat4 introduced by QLoRA).

  • Use Case: Running massive LLMs (like 70B+ parameter models) on local consumer GPUs (e.g., running a model that normally needs 140GB of VRAM on a single desktop GPU).

  • Trade-off: A slight degradation in perplexity/accuracy, though advanced algorithms minimize this impact heavily.

5. 2-bit Quantization (INT2)

  • Precision: Ultra-low precision, packing multiple weights into a single byte.

  • Use Case: Highly constrained edge devices, microcontrollers, or extreme compression research where fitting a model into minimal memory is paramount.

  • Trade-off: Noticeable drop in model intelligence and accuracy unless specialized, highly sophisticated quantization-aware training methods are applied.

Summary Comparison Table

Bit-WidthMemory per ParameterRelative Size (vs FP32)Typical Accuracy ImpactPrimary Use Case
32-bit (FP32)4 bytes100%Baseline (None)Training
16-bit (FP16/BF16)2 bytes50%NegligibleStandard Inference & Training
8-bit (INT8)1 byte25%Very LowEfficient Production Deployment
4-bit (INT4/NF4)0.5 bytes12.5%Low to ModerateRunning Large LLMs locally
2-bit (INT2)0.25 bytes6.25%Moderate to HighExtreme edge computing
sources:
https://www.cloudflare.com/learning/ai/what-is-quantization/
https://medium.com/@isanghao/what-is-quantization-and-why-it-matters-for-inference-c62135f7cfa7
https://huggingface.co/docs/transformers/main_classes/quantization
https://medium.com/@isanghao/optimizing-llm-inference-with-dynamic-quantization-056026701667
https://medium.com/@isanghao/io-bound-or-compute-bound-in-ai-c9c541cd6696
https://developer.nvidia.com/blog/model-quantization-concepts-methods-and-why-it-matters/
https://www.ibm.com/think/topics/quantization
https://developers.google.com/edge/litert/conversion/tensorflow/quantization/post_training_quantization
https://www.medoid.ai/blog/a-hands-on-walkthrough-on-model-quantization/

 

IIFE(Immediately Invoked Function Expression)

IIFE(Immediately Invoked Function Expression)

IIFE = Immediately Invoked Function Expression 

 invokes itself when defined


normal JS function 

function () {

  // Code to run

};

Parentheses(fn) around the function tell JavaScript to treat the function as an expression.

(function () {

  // Code to run immediately

})

Function expressions will execute automatically if the expression is followed by ().

(function () {

  // Code to run immediately

})();


eg:

with arrow function () =>

(() => { 

  // Code runs immediately here 

})();


src:

https://www.w3schools.com/js/js_function_iife.asp


JavaScript modules often replace the need for IIFEs.

Modules have their own scope by default


IIFEs cannot be called again.


Delegate-CH

Delegate-CH

Delegate-CH is an HTML meta tag or HTTP header used in web development to delegate high-entropy User-Agent Client Hints to cross-origin or third-party domains 


those that are sent with every request (Low Entropy Client Hints) 

those that must specifically be requested by the server (High Entropy Client Hints)


It works alongside or similarly to a Permissions Policy to safely grant third parties access to specific client data


sources/further_reading 

https://github.com/WICG/client-hints-infrastructure

https://51degrees.com/blog/implementing-user-agent-client-hints

https://docs.scientiamobile.com/guides/implementing-useragent-clienthints

https://datatracker.ietf.org/doc/html/rfc8942



aiohttp

aiohttp

https://docs.python.org/3/library/asyncio.html

https://docs.aiohttp.org/en/stable/

 

pip install aiohttp
pip install aiohttp[speedups]
 
reads:
https://hackernoon.com/asynchronous-python-45df84b82434
 
https://naive-many.com/bk3.VG0EPH3EpevCb/mMVUJlZgDD0-3yMZj_Ai3IM-TrUizVLGT/cVyIMuD/cNx/NSTccq