I need to review Terraform sometimes, so I left a tutorial+terminology so that I can recall it quickly.
Install https://www.terraform.io/downloads https://learn.hashicorp.com/tutorials/terraform/install-cli
On Ubuntu 21:
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" sudo apt-get update && sudo apt-get install terraform Check:
➜ terraform --version Terraform v1.1.2 on linux_amd64 Configure tab completion.
Best entry video Functional Programming in 40 Minutes • Russ Olsen • GOTO 2018
You can find the slide here.
Mindset We don’t need to put our knowledge aside when learning functional programming. It’s more of a refactoring. Functions in mathmatics It’s just maps from set to set. Functions donn’t compute somthing in math. It just is. A thing. Once the function was defined, the input-output correspondence never changes by other factors, which means, there is no side effects.
Concept TL;DR: DB consists of tables, and items in table have sort of “kay-value”. The main contents (attributes, ~values of key-value) is json.
Table In table, we put items. Each items has “attributes”. Every items must have a “partition key (or primary key)” attribute. Each items could have “sort key” attribute. “We can think of the parition as a folder/bucket which contains items. And the sort key orders the items within the folder/bucket.
Follow the official document.
https://starship.rs
Install Pre-requirement: nerd font Download ttf files and place under ~/.fonts, and reboot.
Check my fonts:
$ fc-list ... /home/atlex00/.fonts/JetBrains Mono Medium Nerd Font Complete Windows Compatible.ttf: JetBrainsMono NF:style=Medium,Regular ... If you want to install the fonts system-wide, place them under /usr/local/share/fonts.
Install Startship prompt Here is the full log:
$ sh -c "$(curl -fsSL https://starship.rs/install.sh)" Configuration > Bin directory: /usr/local/bin > Platform: unknown-linux-musl > Arch: x86_64 > Tarball URL: https://github.
Install AWS CLI 2 On MacOS https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html#cliv2-mac-install-cmd-all-users
% curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg" % sudo installer -pkg AWSCLIV2.pkg -target / % aws --version aws-cli/2.0.18 Python/3.7.4 Darwin/19.5.0 botocore/2.0.0dev22 On Linux (Ubuntu) https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" $ unzip awscliv2.zip $ sudo ./aws/install $ aws --version aws-cli/2.4.6 Python/3.8.8 Linux/5.15.5-76051505-generic exe/x86_64.*** prompt/off ### When you want to update the CLI version ### Download the latest version (zip) and cd ./aws sudo ./install --update Create a CLI access key Login, and go IAM console.
Concept Docker Compose enable us to manage multi container environments in a file.
Install As of Dec.2021 On Ubuntu 20.04 V2 https://docs.docker.com/compose/cli-command/#install-on-linux
$ mkdir -p ~/.docker/cli-plugins/ $ curl -SL https://github.com/docker/compose/releases/download/v2.0.1/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose $ chmod +x ~/.docker/cli-plugins/docker-compose $ docker compose version Docker Compose version v2.0.1 Sample: php-fpm with Nginx Directory structure $ tree . ├── README.md ├── docker-compose.yml ├── front-php │ └── Dockerfile └── nginx_conf └── front.conf docker-compose.yml:
version: "3" services: front-nginx: image: nginx:latest container_name: front-nginx ports: - "80:80" volumes: - {{ path_to_php-fpm_app }}/myconf.
During the Corona situation, I decided to learn something new, and it was lattice-based cryptography.
Intro to LWE from knapsack problem From this slide
1D (modular) knapsack problem Given $a_1, a_2,\cdots, a_n$ and $t$, $q$, where all variables are integers. Find $\{x_i\}_{i=1}^{n}\in\{0, 1\}^{n}$ s.t. , $$ t=\sum_{i=1}^{n}x_1a_i \bmod q. $$
Vector modular knapsack problem Given $\pmb{a}_1, \pmb{a}_2,\cdots, \pmb{a}_n$ and $\pmb{t}$, $q$, where $\pmb{a},\pmb{t}\in\mathbb{Z}^{m\times1}$ and $q \in \mathbb{Z}$. Find $\pmb{x}=\{x_i\}_{i=1}^{n}\in\{0,1\}^{m\times1}$ s.t. , $$ \pmb{t}=\sum_{i=1}^{n}x_i\pmb{a}_i \bmod q.
Materials https://gitready.com/beginner/2009/02/17/how-git-stores-your-data.html https://de.slideshare.net/JeffKunkle/understanding-git Object types in Git Blob Tree Commit Tag <= Skip in this post These objects are stored in .git/objects/.
How to read the objects Git objects are compressed.
# Get file information $ git ls-files -s {{ my_git-managed_file }} 100644 4be0b2b8b0fd36b8b3c94c46b4af4cfb2558d11c 0 {{ my_git-managed_file }} # Decompress the Git object $ pigz -d < .git/objeccts/4b/e0b2b8b0fd36b8b3c94c46b4af4cfb2558d11c blob 7572my Markdown file!! # Another object (tree) $ git ls-tree HEAD // --- snipp --- // 040000 tree 423d17368f16ff18aac8ee494e27bafef8587afa content $ pigz -d < .
My real case Migrate repository from BitBucket to GitHub. I could delete Commit histories. What I’ve done Update .gitignore. Delete docs directory. Update netlify.toml [build] publish = "docs" command = "hugo --gc --minify" [context.production.environment] HUGO_VERSION = "0.87.0" rm -rf data #old dir structure rm -rf .git rm -rf theme/mainroad git init git submodule add git@github.com:Vimux/Mainroad.git themes/mainroad git config --global user.name atlex00 git config --global user.email ... git commit git push origin master --force
Render static images Place your image file under static directory. E.g., static/cat1/my_image.png. Refer the image without static. e.g., /cat1/my_image.png. ![alt text](/cat1/my_image.png "This is a caption.") Add captions Using Markdown render hooks The main idea is, we can overwrite how to convert image lines in markdown into HTML by create the template file layouts/_default/_markup/render-image.html.
I copied the logic from this page (Thank you, Sebastian!)
If title is specified, render by <figcaption> tag.