learning Rust Series: Perfect Number

This will be a part of a series on my rust-learning journey. The goal of this post is to document my process of creating a simple program that determine if the number given is a perfect number1. And also list the perfect number until the given number. Imports 1 use std::io; This is the common input / output modules. Function to determine the perfect number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 fn is_perfect_number(n: i32) -> bool { let mut sum: i32 = 1; let mut i: i32 = 2; while i * i <= n { if n % i == 0 { sum = sum + i + n / i; } i += 1; } if sum == n && n !...

June 17, 2024 · (updated August 5, 2024) · 4 min · 791 words · Kristian Alexander P

Org Mode Workflow

Table of Contents How I mapped my brain to org-mode Basically what I want is The 5 Steps from David Allen’s GTD Method Capture Clarify Organize Reflect Engage What I will need References Using org-mode Keybindings Specific org-mode variables org-directory and org-agenda-files org-archive-location org-todo-keywords Priority Tags Deadlines and Schedules Time-stamp Deadline Schedule The Agenda view. Configuring org-agenda-custom-commands Refiling and archiving Archiving Refiling Things of interest Using org-capture Capturing with templates Things of interest Synchronization, Capture Methods and everything else org-mode extensions Evil-mode org-fancy-priorities org-modern builtin packages saveplace savehist various files configuration How I mapped my brain to org-mode Lately I found that I am in dire need of an effective task management system as an IT support....

March 14, 2024 · (updated August 5, 2024) · 24 min · 4945 words · Kristian Alexander P

Using Terminal Multiplexer

What is a terminal multiplexer? let wikipedia do the talking: A terminal multiplexer is a software application that can be used to multiplex several separate pseudoterminal-based login sessions inside a single terminal display, terminal emulator window, PC/workstation system console, or remote login session, or to detach and reattach sessions from a terminal. It is useful for dealing with multiple programs from a command line interface, and for separating programs from the session of the Unix shell that started the program, particularly so a remote process continues running even when the user is disconnected....

March 13, 2024 · (updated August 5, 2024) · 2 min · 397 words · Kristian Alexander P

Literate Configuration with Emacs

Background I’m spending most of my long vacation reorganizing my github repositories, archiving some old repos (mostly android stuffs that I don’t use anymore). And when I’m looking into my dotfiles repos I remember once I’ve tried to use literate programming to manage them. I think one of the difficulties I had was editing the source code block inline. 1 2 3 4 This is how shell code block looks like in /Emacs/ #+begin_src sh echo true #+end_src Editing code blocks inline has many disadvantages, for one, indentation is quite tricky....

March 12, 2024 · (updated August 5, 2024) · 2 min · 417 words · Kristian Alexander P

Hugo blog org-capture-templates

Blogging with org-mode I do almost all my note-taking in Emacs org-mode, so naturally I also prefer to write my blog posts in it. As for my ox-hugo blogging flow, I use the less preferred method: one org file per post, the consequence is I cannot just copy-paste the org capture setup provided by the doc site. I also setup my posts in a subdirectory beneath the HUGO_BASE_DIR: 1 tree -n ....

March 3, 2024 · (updated August 5, 2024) · 10 min · 2101 words · Kristian Alexander P

Emacs Version Control

Magit Magit is a complete text-based user interface to Git. It fills the glaring gap between the Git command-line interface and various GUIs, letting you perform trivial as well as elaborate version control tasks with just a couple of mnemonic key presses. Magit looks like a prettified version of what you get after running a few Git commands but in Magit every bit of visible information is also actionable to an extent that goes far beyond what any Git GUI provides and it takes care of automatically refreshing this output when it becomes outdated....

February 29, 2024 · (updated August 5, 2024) · 7 min · 1396 words · Kristian Alexander P

Emacs shell

Eshell It is a shell written in Emacs Lisp. Eshell is both a command shell and an Emacs Lisp REPL (Read Eval Print Loop), as a result, you can invoke commands in two different ways: command form or in Lisp form. As always, the official documentation provides you with more than enough information on Eshell. Figure 1: Eshell Command form Command form looks much the same as in other shells. A command consists of arguments separated by spaces; the first argument is the command to run, with any subsequent arguments being passed to that command....

February 28, 2024 · (updated August 5, 2024) · 2 min · 241 words · Kristian Alexander P

Theming Emacs

Why? Figure 1: Default Emacs UI For those who prefer a universal theme in their destop, the default Emacs interface is kind of ugly. Though there are built-in themes included, to be fair the options are limited. Figure 2: emacs wombat theme, one of the better ones Doom When I first tried Emacs, Doomemacs was my first choice. It’s kind of a “curated default configurations”. Figure 3: doom emacs, image from their github page...

February 27, 2024 · (updated August 5, 2024) · 2 min · 268 words · Kristian Alexander P

Emacs Evil

Evil is an extensible vi layer for Emacs. It emulates the main features of Vim, and provides facilities for writing custom extensions. Installing Add Melpa 1 2 (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) Code Snippet 1: melpa with use-package 1 2 3 4 5 6 7 8 9 10 11 12 13 14 (use-package evil :ensure :preface (customize-set-variable 'evil-want-keybinding nil) ;; if using `evil-collection' (customize-set-variable 'evil-want-integration t) ;; if using `evil-collection' (customize-set-variable 'evil-undo-system 'undo-redo) (customize-set-variable 'evil-want-C-u-scroll t) ;; move universal arg to <leader> u (customize-set-variable 'evil-want-C-u-delete t) ;; delete back to indentation in insert state (customize-set-variable 'evil-want-C-g-bindings t) :config (evil-mode 1) ;; disable this when using `general....

February 25, 2024 · (updated August 5, 2024) · 3 min · 500 words · Kristian Alexander P

Emacs general.el

About general.el provides a more convenient method for binding keys in emacs (for both evil and non-evil users). Like use-package, which provides a convenient, unified interface for managing packages, general.el is intended to provide a convenient, unified interface for key definitions. While this package does implement some completely new functionality (such as the ability to make vim-style keybindings under non-prefix keys with an optional timeout), its primary purpose is to build on existing functionality to make key definition more clear and concise....

February 24, 2024 · (updated August 5, 2024) · 3 min · 612 words · Kristian Alexander P