xrandr, 2

xrandr -q

xrandr --output DisplayPort-3 --auto --primary --output HDMI-A-4 --auto --left-of DisplayPort-3

xrandr --output DisplayPort-3 --auto --primary --output HDMI-A-4 --off

— Me@2025-04-20 02:19:35 PM

.

.

2025.04.20 Sunday (c) All rights reserved by ACHK

SageMath for Ubuntu 24.04

0. In this tutorial, you will need to go to the official website of NixOS. Make sure that its website is the real, official one. Any instructions from an imposter website can get your machine infected with malware.

1. Assuming your computer’s OS is Ubuntu 24.04 or above, go to the NixOS official website. Follow the instructions to install the Nix package manager (not the NixOS operating system) onto your OS. Choose the “single-user installation” method.

.

2. Run this command to install SageMath:

nix-env -iA nixpkgs.sage

3. Run this to open:

sage --notebook=jupyterlab

— Me@2024-11-27 12:28:48 AM

.

.

2024.12.24 Tuesday (c) All rights reserved by ACHK

scmutils for Ubuntu 24.04

Scheme Mechanics Installation for GNU/Linux | scmutils, 4

.

1. Folks, the scmutils library is fantastic and it’s available in Ubuntu 24.04. You can install it very easily with this command:

sudo apt-get install scmutils

2. Then, you just run it with this command:

mit-scheme --band mechanics.com

.

Now, let me tell you, there’s no syntax highlighting. Not great! And more importantly, there’s no direct way to save your code. So, what do you do? You use the Emacs editor. It’s the best!

Now, this assumes you know Emacs. If you don’t, it’s a tremendous editor.

3. Open Emacs’ initialization file. It’s located right here:

~/.emacs

4. Add this beautiful code to the file:

(defun mechanics ()
  (interactive)
  (run-scheme
   "mit-scheme --band mechanics.com"))
(setq sicm-file "~/Documents/tt.scm")

(fset 'set-working-file
      (lambda (&optional arg) 
        (interactive "p")
        (funcall (lambda ()
                   (insert
                    (concat "(define sicm-file \""
                            sicm-file
                            "\")\n"))))))

(fset 'load-scm
      (lambda (&optional arg) 
        (interactive "p")
        (funcall (lambda ()
                   (insert "(load sicm-file)")))))

(defun mechan ()
  (interactive)
  (split-window-below)
  (windmove-down)
  (mechanics)
  (set-working-file)
  (comint-send-input)
  (windmove-up)
  (find-file sicm-file)
  (end-of-buffer)
  (windmove-down)
  (cond ((file-exists-p sicm-file)
         (interactive)
         (load-scm)
         (comint-send-input)))
  (windmove-up))

(defun sicm-exec-line ()
  (interactive)
  (save-buffer)
  (windmove-down)
  (comint-send-input)
  (windmove-up))

(defun sicm-exec-file ()
  (interactive)
  (save-buffer)
  (windmove-down)
  (load-scm)
  (comint-send-input)
  (windmove-up))

(global-set-key (kbd "C-x C-e") 'sicm-exec-line)

(global-set-key (kbd "C-x C-a") 'sicm-exec-file)

5. Close Emacs and then re-open it, folks.

6. Type the command

M-x mechan

Now, listen, when I say M-x, I mean you press the Alt key and x together. Then, just type mechan. It’s easy, believe me!

7. You’ll see the Emacs editor split into two windows, one on top and one on the bottom.

The lower window is the Scheme environment. You can type a line of code and then press Enter to execute it. So simple!

The upper window is the editor. Type multiple lines of code and then hit

C-x C-e

to execute it.

That means pressing Ctrl and x together, then Ctrl and e together. Easy stuff!

8. When you save the current file, your Scheme code will be saved to this location:

~/Documents/tt.scm

If you need to back up your code, just back up this file. It’s that simple, folks!

— Me@2020-03-10 10:59:45 PM

.

.

2024.12.01 Sunday (c) All rights reserved by ACHK

Eject

Safely unmounts the partition /dev/sdd1, ensuring that it is not in use.

udisksctl unmount -b /dev/sdd1

udisksctl power-off -b /dev/sdd

Powers off the entire block device /dev/sdd, making it safe to disconnect.

— Me@2024-01-12 06:47:59 PM

.

.

2024.11.22 Friday (c) All rights reserved by ACHK

Mounting a virtual disk

# In the host OS, if you want to read the contents of a virtual disk file:

mkdir ~/vdi_test_mount

sudo guestmount -a my_virtual_drive.vdi -m /dev/sda1 -o allow_other ~/vdi_test_mount

# After that, unmount the virtual disk:

sudo guestunmount ~/vdi_test_mount

rmdir ~/vdi_test_mount

— Me@2023-11-25 10:03:37 PM

.

.

2024.11.10 Sunday (c) All rights reserved by ACHK

DSE 數學補邊個好?(神器六)

這篇文章繼續討論,選擇數學補習老師的一些準則。而這裡的數學,是指香港中學文憑試的數學科,包括核心,M1 及 M2。

如果你問我物理補習推介,特別是物理補習天王的話,我會答:「補 physics,補 Ken Chan!」但是,如果你問我數學補習天王的話,恕沒有推介,因為本人沒有遇過。

那樣,數學科補習界如果有 Ken Chan,他又必須具備,什麼條件呢?

上文提到:

……

3. 星期時間篇

他會告訴你,如何從平衡到駕馭,各科溫習時間之爭。

……

4.0 分秒時間篇

除了日常生活中的,溫習時間管理外,他亦會教你,考試答題時的時間策略。

……

4.\infty 數學考試

= 兩成數學 + 八成人格(速度+準確度+表達)

……

5. 超時空準備

他會持續教導你,比考試要求,還深一倍的題目。目的就是令你,有奪取滿分的機會。

作為「附加數學」的 M1 或 M2,主要作用是令你覺得,作為「普通數學」的核心數,簡單而容易。

水平提高了,原地就會在你之下。再困難的迷宮,如果有直升機的協助,就不用再怕。一來,你可以直升離開;二來,即使必須降回原地,單單是在直升機的那幾分鐘,足以讓你鳥瞰原地全境。

同理,如果要令自己「附加數」本身,有機會滿分的話,則要熟習「附加附加數」,即是大學一年級程度的數學。

迷宮必勝法,用直升機也;簡稱「降維打擊」。其先決條件是,你要花大量時間,預先「升維」。

— Me@2024-10-26 11:23:52 PM

.

.

2024.10.27 Sunday (c) All rights reserved by ACHK

DSE 數學補邊個好?(神器五)

這篇文章繼續討論,選擇數學補習老師的一些準則。而這裡的數學,是指香港中學文憑試的數學科,包括核心,M1 及 M2。

如果你問我物理補習推介,特別是物理補習天王的話,我會答:「補 physics,補 Ken Chan!」但是,如果你問我數學補習天王的話,恕沒有推介,因為本人沒有遇過。

那樣,數學科補習界如果有 Ken Chan,他又必須具備,什麼條件呢?

上文提到:

1. 背誦篇

理科是文科,但不是一般的文科,而是極超巨大級的文科。

1.1 他會提醒你,數學其實是,極超大量的背誦。

……

1.2 極超大量的背誦,來自極端深刻的理解。

……

2. 年月時間篇:歷屆試題

2.1 他會提議你,考試前要操練 10 年、20 年 或 30 年的歷屆試題。

……

2.1.2 他會告訴你「八二法則」——頭八十分,只需兩成的付出;而尾二十分,則需佔八成的努力。亦即是話,付出和收穫,不成比例。

……

2.2 最近五年的題目,則從來不要看,因為你要保留它們,在公開試前的休假月時,來作模擬考試用。

2.3 最近五年以前的題目,則可以在課程的那三年間,隨時隨地做。

留意,做試題有兩大主要方法:「分課題」或「分年份」。

……

2.4 而歷屆試題的來源是:……

3. 星期時間篇

他會告訴你,如何從平衡到駕馭,各科溫習時間之爭。

……

4.0 分秒時間篇

除了日常生活中的,溫習時間管理外,他亦會教你,考試答題時的時間策略。那都是要在事先,學習和訓練的。

有關詳情,請點擊本綱誌之文章分類

exam time | 戰鬥意志

然後於網址結尾,加以下字串:

?order=asc

例如,剛才提到的「八二原則」指出了:同樣的分數,在不同的部分,難易不同。所以,考試時應先做最易的題目。

留意,題目的預設次序,未必是由易至深。其中一個原因是,各人對即使是同一道題目,深淺的感覺,未必相同。所以,必須在考試前鐵定,「唔識就飛」的好習慣:遇到不懂的題目時,不要思考,改為立刻跳過,去先做懂做的題目;最後還有時間剩餘時,才回到不懂的題目。

4.1 他會教你如何高速作答。

留意,高速不是急促。高速的原因在於,你掌握的數學知識,深於常人所及;繼而,你駕馭的運算技巧,高過他人所能。

每個課題的深知識,和對應的速算技巧,也可以不同,也可以是該課獨家。亦即是話,每種題目的速算技巧,都要遠在考試前就,事先學習和訓練好。

4.2 同理,每課題目的驗算技巧,亦都是那樣。

4.3 他亦會教你,考試作答時的表達技巧。自以為「數學和理科,毋須語文能力」的,是狂妄。

4.\infty 為了方便記憶,背了這公式:

數學考試

= 兩成數學 + 八成人格(速度+準確度+表達)

公式中的「準確度」,是指「數字準確度」或「運算準確度」。而「表達」,則指「文字準確度」或「語文準確度」。數學考試成績反映的,大概而言,只有兩成是數學中的,所謂「純知識」;其餘八成,都是人格的考驗。

有些數學知識,只在考試有益;而人格才能,則一生受用。

5.

……

— Me@2024-10-10 08:01:07 PM

.

.

2024.10.12 Saturday (c) All rights reserved by ACHK

xrandr

Quantum Mechanics: End Game

.

physical definition

~ define microscopic events in terms of observable physical phenomena, such as the changes in readings of the measuring device

~ define unobservable events in terms of observable events

— Me@2022-01-31 08:33:01 AM
 

.

I give you the final answer to this topic. You should continue to study this topic until you understand that.

A mixed state exists due to the lack of information.

A superposition state exists not due to that.

A superposition state exists due to the lack of a physical definition.

An eigenstate and a superposition state are both pure states.

A superposition state is neither an AND nor an OR because it is a pure state, meaning that it is one single quantum state, not a mixture of two.

A mixed state is an OR.

xrandr --output DP-0 --auto --output HDMI-0 --left-of DP-0

In the realm of knowledge, I share with you,
The final answer, clear and true.
Study deeply, let curiosity flow,
Until this truth, you truly know.

A mixed state emerges, shrouded in doubt,
Born from the shadows where facts are left out.
Yet a superposition, distinct in its grace,
Doesn’t arise from that uncertain place.

It finds its definition in the absence of form,
A concept elusive, where ideas transform.
Both eigenstates and superpositions, pure,
In the quantum dance, their essence is sure.

Neither an AND nor an OR, it stands alone,
One single state, in the vastness, it’s grown.
Not a blend of two, but a singular hue,
While a mixed state proclaims, “I am an OR,” too.

— Me@2024-08-19 03:23:59 PM

— Me@2024-09-30 03:40:25 PM

.

.

2024.10.01 Tuesday (c) All rights reserved by ACHK

DSE 數學補邊個好?(神器四)

這篇文章繼續討論,選擇數學補習老師的一些準則。而這裡的數學,是指香港中學文憑試的數學科,包括核心,M1 及 M2。

如果你問我物理補習推介,特別是物理補習天王的話,我會答:「補 physics,補 Ken Chan!」但是,如果你問我數學補習天王的話,恕沒有推介,因為本人沒有遇過。

那樣,數學科補習界如果有 Ken Chan,他又必須具備,什麼條件呢?

上文提到:

1. 背誦篇

理科是文科,但不是一般的文科,而是極超巨大級的文科。

1.1 他會提醒你,數學其實是,極超大量的背誦。

……

1.2 極超大量的背誦,來自極端深刻的理解。

……

2. 年月時間篇:歷屆試題

2.1 他會提議你,考試前要操練 10 年、20 年 或 30 年的歷屆試題。

……

2.1.2 他會告訴你「八二法則」——頭八十分,只需兩成的付出;而尾二十分,則需佔八成的努力。亦即是話,付出和收穫,不成比例。

……

2.2 最近五年的題目,則從來不要看,因為你要保留它們,在公開試前的休假月時,來作模擬考試用。

2.3 最近五年以前的題目,則可以在課程的那三年間,隨時隨地做。

留意,做試題有兩大主要方法:「分課題」或「分年份」。

……

2.4 而歷屆試題的來源是:……

3. 星期時間篇

他會告訴你,如何從平衡到駕馭,各科溫習時間之爭。

其方法是,用自動時間表——透過預先設計好的時間程式,每天自動生成的時間表。每天你毋須花額外時間,人手編配時間表,考慮溫什麼。

該機械化時間表,會自動編排和分配,各科的溫習時間和長度。同一天會由,不同類型科目組合而成,導致腦部的不同部分,可以輪流休息,即使整體的工作時數很多。

該系統化時間表,會有適當分割,導致溫習不會辛苦。

有關詳情,請點擊本綱誌之文章分類

in-time-時來運到

然後於網址結尾,加以下字串:

?order=asc

記住,刻苦不能長久,因為你的潛意識,會無時無刻,找機會「逃走」。那就是「疲倦」的真正動機。

你工作系統的目標,並不是「控制自己」——控制不想讀書的自己讀書,勉強自己做不想做的事;而是「釋放自己」——釋放學習動機,爆發學術潛能。

頭腦清醒時,靈感才會自來,天份才能發揮。

4. 分秒時間篇

……

5.

……

6.

……

— Me@2024-09-28 11:11:52 AM

.

.

2024.09.29 Sunday (c) All rights reserved by ACHK

KDE Chinese, 2.2

<div style="color: #333333; font-size: 20px; font-family: AR PL UKai TW">
楷書測試
</div>
楷書測試

The above Chinese characters should be displayed in the regular script font (楷書). Otherwise, you need to install this package on your Linux distribution:

fonts-arphic-ukai

— Me@2024-08-13 01:41:14 PM

.

.

2024.08.30 Friday (c) All rights reserved by ACHK

Zsh, 3

1. Assuming you have already installed the Nix package manager on Ubuntu 22.04 or later, type the following command into the terminal:

nix-env -iA nixpkgs.zsh-autocomplete  

2. Open the Zsh configuration file:

~/.zshrc

Add the following lines to it:

source ~/.nix-profile/share/zsh-autocomplete/zsh-autocomplete.plugin.zsh
 
bindkey -M menuselect '\e' undo

— Me@2024-01-23 08:52:05 AM

.

.

2024.08.01 Thursday (c) All rights reserved by ACHK

NixOS config

Zsh, 4

.

# Edit this configuration file to define what should be installed on your system.  Help is available in the configuration.nix(5) man page and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Bootloader.
  boot.loader.grub.enable = true;
  boot.loader.grub.device = "/dev/sda";
  boot.loader.grub.useOSProber = true;

  networking.hostName = "hi"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.
  networking.wireless.enable = false;
  hardware.bluetooth.enable = false;

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Australia/Perth";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "en_GB.UTF-8";
    LC_IDENTIFICATION = "en_GB.UTF-8";
    LC_MEASUREMENT = "en_GB.UTF-8";
    LC_MONETARY = "en_GB.UTF-8";
    LC_NAME = "en_GB.UTF-8";
    LC_NUMERIC = "en_GB.UTF-8";
    LC_PAPER = "en_GB.UTF-8";
    LC_TELEPHONE = "en_GB.UTF-8";
    LC_TIME = "en_GB.UTF-8";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the KDE Plasma Desktop Environment.
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.desktopManager.plasma5.enable = true;

  # Configure keymap in X11
  services.xserver = {
    layout = "us";
    xkbVariant = "";
  };

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default, no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.hi = {
    isNormalUser = true;
    description = "hi";
    extraGroups = [ "networkmanager" "wheel" "vboxsf" "vboxusers"];
    shell = pkgs.zsh;
    packages = with pkgs; [
      firefox
      kate
      thunderbird
      chromium
    ];
  };

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # virtualisation.virtualbox.guest.enable = true;
  # virtualisation.virtualbox.guest.x11 = true;
  # virtualisation.virtualbox.host.enable = true;
  # virtualisation.virtualbox.host.enableExtensionPack = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
  #  vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
  #  wget
    zsh
    zsh-autosuggestions
    zsh-syntax-highlighting
    zsh-powerlevel10k
    meslo-lgs-nf

    oh-my-zsh
    corefonts
    fira
    powerline-fonts
    ubuntu_font_family
    unifont

    p7zip
    unrar
    unzip

    util-linux
    meld

    home-manager

    git
    git-cola
    github-desktop

    emacs29

    autokey
    virtualbox
    librewolf
    palemoon-bin
    ventoy-full

    flatpak
    steam
    libsForQt5.falkon
    libsForQt5.korganizer
    krusader

    psensor
    playonlinux
    protonvpn-gui

    # vmware-workstation

    quickemu
    quickgui

    neofetch
  ];

  # Some programs need SUID wrappers, can be configured further or are   # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  programs.zsh = {
    enable = true;
    enableCompletion = true;
    autosuggestions.enable = true;
    interactiveShellInit = ''
      source /run/current-system/sw/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
      source /run/current-system/sw/share/zsh-autosuggestions/zsh-autosuggestions.zsh
      source /run/current-system/sw/share/zsh-powerlevel10k/powerlevel10k.zsh-theme
    '';
  };

  fonts = {
    fontDir.enable = true;
    packages = with pkgs; [
      corefonts
      fira
      powerline-fonts
      ubuntu_font_family
      unifont
    ];
  };

  # List services that you want to enable:

   systemd.services.rfkill-block-all = {
     path = [ pkgs.networkmanager ];
     script = ''
       nmcli radio wifi off
     '';
     wantedBy = [ "multi-user.target" ];
   };

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  networking.firewall.enable = true;
  powerManagement.enable = true;
  services.thermald.enable = true;

  # This value determines the NixOS release from which the default settings for stateful data, like file locations and database versions on your system were taken. It‘s perfectly fine and recommended to leave this value at the release version of the first install of this system. Before changing this value read the documentation for this option (e.g. man configuration.nix or on ... ).
  system.stateVersion = "23.11"; # Did you read the comment?
}

— Me@2024-01-23 09:55:24 AM

.

.

2024.02.29 Thursday (c) All rights reserved by ACHK

7z to encrypt folder with AES 256

Sequential speed, 2 | Restore, 2

.

7za a -mmt4 -tzip -p -mem=AES256 /target_folder/the_zip_file.zip /source_folder/

a

Add files to archive

-mmt[N]

set number of CPU threads

-t{Type}

Set type of archive

-p{Password}

set Password

-m{Parameters}

set compression Method

.

How to check the encryption algorithm of a 7z/zip file?

7z l -slt /target_folder/file.zip

l

List contents of archive

-slt

show technical information for l (List) command

.
To unzip:

7za x /source_folder/the_zip_file.7z -o/target_folder/

x

eXtract files with full paths

-o{Directory}

set Output directory

— Me@2023-11-26 12:17:46 PM

.

.

2024.01.14 Sunday (c) All rights reserved by ACHK

Quicklisp error

Common Lisp calculator, 2

.

1. To run the following code, you have to install the Quicklisp library manager by following the steps in my blog post titled cmu-infix.

.

2.1 To enable the library, in the Common Lisp REPL, run the code:

(ql:quickload :cmu-infix)

(named-readtables:in-readtable cmu-infix:syntax)

2.2 If you encounter the error message:

Lisp connection closed unexpectedly: connection broken by remote peer

2.2.1 empty the cache folder:

~/.cache/common-lisp/

2.2.2 Restart the Common Lisp REPL.

2.2.3 Reload the library.

.

3.1 The goal of the following code is to create our own REPL.

(defmacro infix-string-eval (a-string)
  `(eval (read-from-string
          (concatenate 'string
                       "#I (" ,a-string ")"))))

(defun read-repl-all ()
  (loop (print (write-to-string (read)))))

(defun my-repl ()
  (loop
    (let ((a-string (write-to-string (read))))
      (if (or (string-equal "(exit)" a-string)
              (string-equal "exit" a-string))
          (return)            
          (print
           (infix-string-eval
            (string-trim "|()" a-string))))))) 

3.2 In the Common Lisp REPL, run the code:

(my-repl)

— Me@2022-12-26 01:10:34 PM

.

The symbol

^

is the bitwise exclusive OR.

To create an exponentiation, we use

^^

— Me@2023-09-09 12:51:46 PM

.

— Me@2023-11-22 12:56:00 PM

.

.

2023.11.23 Thursday (c) All rights reserved by ACHK

KDE Wifi

Sometimes, KDE Plasma keeps turning off wifi during every startup. To solve this problem:

1. Type this command to the terminal:

sudo emacs \ 
/etc/systemd/system/unb-wifi.service

1.1 If you like, you can replace

emacs

with your favourite editor’s name in this command.

1.2 The goal of this command is to create the new text file

unb-wifi.service

.

2.1 Copy and paste the following code to the text file.

[Unit]
Description=Unblock WiFi Devices

[Service]
Type=oneshot
ExecStart=/usr/sbin/rfkill unblock wifi
ExecStart=/usr/bin/nmcli radio wifi on
ExecStop=
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

2.2 Save the file and exit the editor.

.

3.1 Execute this command in bash terminal:

sudo systemctl enable \ 
unb-wifi.service

If you get any errors, try this instead:

sudo systemctl enable \ 
/etc/systemd/system/unb-wifi.service

3.2 Then, execute also:

sudo systemctl start \ 
unb-wifi.service

If you get any errors, try this instead:

sudo systemctl start \ 
/etc/systemd/system/unb-wifi.service

3.3 If you still get errors, restart your computer.

Check if the wifi is already on.

— Me@2023-11-05 12:56:05 PM

.

.

2023.11.06 Monday (c) All rights reserved by ACHK

Picasa

This is a file from the Wikimedia Commons.

Picasa was a cross-platform image organizer and image viewer for organizing and editing digital photos, integrated with a now defunct photo-sharing website, originally created by a company named Lifescape (which at that time was incubated by Idealab) in 2002.

— Wikipedia on Picasa

— Me@2023-10-10 08:09:55 PM

.

.

2023.10.10 Tuesday (c) All rights reserved by ACHK

Common Lisp calculator, 1

To run the following code, you have to install the Quicklisp library manager by following the steps in my blog post titled cmu-infix.

(ql:quickload :infix-math)

(asdf:load-system "infix-math/calc")

(infix-math/calc:calc)

This problem of using this calculator is that spaces are required both before and after an operator:

wrong:

1+1

correct:

1 + 1

— Me@2022-12-26 10:19:05 AM

.

.

2023.09.09 Saturday (c) All rights reserved by ACHK

Sequential speed



--recurse-paths
-r

recurse into directories


--symlinks
-y

store symbolic links as the link instead of the referenced file

.

zip -r -y /dest_folder/the_zip_file.zip /source_folder/

source_folder is the folder to be zipped.

dest_folder is the destination folder for storing the zip file.

After zipping, the resulting file is the_zip_file.zip, which is a zipped version of the source_folder.

— Me@2023-08-03 09:41:29 AM

.

.

2023.08.07 Monday (c) All rights reserved by ACHK

Quicklisp, 2

Euler problem 13

.

To run the following code, you have to install the Quicklisp library manager by following the steps in my blog post titled cmu-infix.

(ql:quickload "str")

(defun file-get-contents (filename)
  (with-open-file (stream filename)
    (let ((contents (make-string
                     (file-length stream))))
      (read-sequence contents stream)
      contents)))

(defun file-get-lines (filename)
  (with-open-file (stream filename)
    (loop :for line = (read-line stream nil)
          :while line
          :collect line)))

(file-get-lines #P"n.txt")

(defun string-to-list (the-string)
  (loop :for char :across the-string
        :collect char))

(defun char-to-integer-list (char-list)
  (mapcar #'digit-char-p char-list))

(let ((the-list (file-get-contents #P"n.txt")))
  (subseq
   (prin1-to-string
    (reduce
     #'+
     (mapcar
      #'parse-integer
      (butlast (str:split #\newline the-list)))))
   0 10))

— Me@2023-05-26 12:16:50 PM

.

.

2023.05.26 Friday (c) All rights reserved by ACHK