Category Theory (Apr.2021. updating continuously)

Materials Category Theory by Steve Awodey Very kind “Category Theory For Beginners” by Richard Southwell. My memo: Introduction done My memo: Functor done Definition of a category Objects and arrows exist. There should be identity arrows for all objects. Arrows should be composited. Associativity holds. Terminology: domain and codomain $\mathrm{dom}(f)\xrightarrow{f} \mathrm{cod}(f)$ Directed graphs and categories If $f:A\rightarrow B$ and $g:B\rightarrow C$ exist but $h := g\cdot f$ doesn’t, it violates the rule of composition.

kind - local Kubernetes cluster using Docker container nodes

My environment Pop!_OS $ uname -a Linux system76 5.11.0-7620-generic #21~1624379747~20.10~3abeff8-Ubuntu SMP Wed Jun 23 02:23:59 UTC x86_64 x86_64 x86_64 GNU/Linux Set up pre-requirements for kind Install latest Go cd /usr/local/src sudo curl -L -O https://golang.org/dl/go1.16.5.linux-amd64.tar.gz tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin /etc/profile PATH=/usr/local/go/bin:$PATH Rootless Docker Refer to my post. Install kubectl https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-using-native-package-management sudo apt install -y apt-transport-https ca-certificates curl sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.

Rootless Docker

My environment Pop!_OS $ uname -a Linux system76 5.11.0-7620-generic #21~1624379747~20.10~3abeff8-Ubuntu SMP Wed Jun 23 02:23:59 UTC x86_64 x86_64 x86_64 GNU/Linux Configure rootless Docker https://docs.docker.com/engine/security/rootless/ $ dockerd-rootless-setuptool.sh install [ERROR] Missing system requirements. Run the following commands to [ERROR] install the requirements and run this tool again. ########## BEGIN ########## sudo sh -eux <<EOF # Install newuidmap & newgidmap binaries apt-get install -y uidmap EOF ########## END ########## OK… Run the command above and try again.

Rust - Getting Started (May. 2021. updating continuously)

What’s this page? As of Jan. 2021, I work as a DevOps (or infrastructure) engineer, but I like to solve problems with codes (front, back, whatever. it depends on the purposes.) For a year, my motivation abour learning Rust surges enough. This page is a memo while I’ve learned with Rust official document so that I can easily reminde the key feafures of Rust. Most part of this post consist of quotes from the document, but I also leave my opinions (could be wrong.

Basic sort algorithms in Rust

Disclamer The implementations in this post has a lot of room to improvement. As of Apr. 2021, they are more like code monkey’s code :( Reverse a string fn main() { let s1 = String::from("Please reverse me with spaces!日本語.한국어"); println!("Original string: {}",s1); let mut s2 = String::from(""); for c in s1.chars().rev() { s2.push(c); } println!("Reversed: {}",s2); } In Rust, both String and a string slice &str are UTF-8 encoded.

Custom configuration, and inject JavaScript in posts

Motivation To enable TikZ in my note, I add a header in layout/partial/header.html at first. But this change injects the javascript lines into all my posts which don’t need to include the TikZ. So I want to inject JavaScript in case that I mark the post as “TikZ enabled”. How to Create a HTML template In layouts/partials/header.html. {{ if and .IsPage (eq (.Param "tikz") true) }} <link rel="stylesheet" type="text/css" href="https://tikzjax.com/v1/fonts.css"> <script src="https://tikzjax.

Use Decorator in Python

Let’s grasp the concept of decorator in Python PEP 318 with short snippets. Step 1: Function as a parameter def f1(): print("Called f1.") def f2(f): f() f2(f1) # Called f1 f2 takes a function (object) as a parameter. Step 2: Wapping function def f1(fun): def wrap(): print("Start wrap") fun() print("End wrap") return wrap def f(): print("In function f") f1(f)() ### python test.py #Start wrap #In function f #End wrap Step 3: Use decorator def f1(fun): def wrap(): print("Start wrap") fun() print("End wrap") return wrap @f1 def f(): print("In function f") f() ### python test.

Rust Serverless

Getting started I followed the link. In this page, the author wrote details and it’s very educational. To remind the procedure, I left memo. I really appreciate you, Chuma Umenze :) Hello world code cargo new rust_lambda Cargo.toml: [package] // --- snip --- autobins = false [dependencies] lambda_runtime = "0.2.1" serde = { version = "^1.0", features = ["derive"] } [[bin]] name = "bootstrap" path = "src/main.rs" src/main.rs: use lambda_runtime::{error::HandlerError, lambda, Context}; use serde::{Deserialize, Serialize}; use std::error::Error; #[derive(Deserialize, Serialize, Clone)] #[serde(rename_all = "camelCase")] struct LambdaRequest { full_name: String, message: Option<String>, } #[derive(Deserialize, Serialize, Clone)] #[serde(rename_all = "camelCase")] struct LambdaResponse { lambda_request: LambdaRequest, } fn main() -> Result<(), Box<dyn Error>> { lambda!

Quick Ansible test

This is memo when I want to run simple tasks quickly. Directory. $ tree . ├── ansible.cfg ├── hosts └── test.yml In hosts. [servers] server1.mydomain.com server2.mydomain.com server3.mydomain.com test.yml. - name: test-playbook hosts: servers tasks: - cron: name: "Add a cron when rebooting" special_time: reboot job: "echo $PATH" user: atlex00 ansible.cfg [defaults] host_key_checking = False deprecation_warnings=False Exec: ansible-playbook ./test.yml -i hosts -bD -C

NVM

What’s nvm Node.js Version Manager. Like pyenv in Python. Different from Python, you can’t label a name to the environment. package.json manage the libraries. Install nvm Follow the official document. https://github.com/nvm-sh/nvm $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash ..... (simple results) $ export NVM_DIR="$HOME/.nvm" $ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm $ [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion Check.