tutorial

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.

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.

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.

Serverless framework - Getting Started with Python

I tried Serverless framework with Python AWS Lambda. Prerequirement Node.js and npm. $ node -v v10.19.0 $ npm -v 7.5.2 Install I created my serverless account with Google SSO. sudo npm install -g serverless Hello world Create a project: $ serverless Serverless: No project detected. Do you want to create a new one? Yes Serverless: What do you want to make? AWS Python Serverless: What do you want to call this project?

Cognito - tutorial

First thing you should decide We should decided “User pool” or “Identity pool”. Here is the official blog post about the differences. https://aws.amazon.com/de/premiumsupport/knowledge-center/cognito-user-pools-identity-pools/ In a nut shell, User pools are for authentication (identify verification), and Identity pools are for authorization (access control). I’ll try an User pool. Future scope: integrate with AppSync. Tutorial 1. Create an User pool I followed the link. Very easy. https://docs.aws.amazon.com/cognito/latest/developerguide/tutorial-create-user-pool.html Choose Manage User Pools. Manage User Pools.

MongoDB - Tutorial

Good tutorial video https://www.youtube.com/watch?v=pWbMrx5rVBE Handson Install on Ubuntu sudo su wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list apt update sudo apt install -y mongodb-org systemctl start mongodb Playground in local Docker container docker run -p 27017:27017 -d mongo:4.0-xenial Toolkit curl https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2004-x86_64-100.3.0.deb -O sudo apt install ./mongodb-database-tools-ubuntu2004-x86_64-100.3.0.deb Mongo shell mkdir mongosh cd mongosh curl https://downloads.mongodb.com/compass/mongosh-0.8.3-linux.tgz -O tar -zxvf mongosh-0.

WASM by Rust - Tutorial

Tutorial The URL I followed. https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_wasm Pre-requirement You should install npm beforehand. To compile wasm-pack, apt install -y build-essential and install gcc. In case of Ubuntu, apt install -y libssl-dev pkg-config. Download wasm-pack To build the package, we need an additional tool, wasm-pack. This helps compile the code to WebAssembly, as well as produce the right packaging for npm. $ cargo install wasm-pack $ cargo new --lib hello-wasm $ cd hello-wasm Write codes src/lib.

AppSync - Tutorial

Getting started Set up Go to AppSync Page. Create API. Getting Started. Customize your API or import from Amazon DynamoDB -> Create with wizard Click Start Create model Model Name: Atlex00Model Configure model fields: Name: uid, Type: ID, Required. Name: first_name: Type: String Name: last_name: Type: String Name: gender: Type: Int Name: age: Type: Int Name: email: Type: Email Configure model table (optional) Table Name: Atlex00ModelTable Primary Key: uid, Sort key: first_name Create resources API configuration API name: atlex00AppSync Your API is almost ready… Updating the schema.

Slow query - MySQL

What is slow query? https://dev.mysql.com/doc/refman/8.0/en/slow-query-log.html The definition “slow query” is “SQL statements that take more than long_query_time seconds to execute and require at least min_examined_row_limit rows to be examined”. Configure Check current status SHOW VARIABLES LIKE "slow_query_log"; SHOW VARIABLES LIKE "slow_query_time"; SHOW VARIABLES LIKE "slow_query_log_file"; Enable to log slow queries Logging slow queries which take more than 10 seconds. SET GLOBAL slow_query_log = 'ON'; SET GLOBAL long_query_time = 10; SET GLOBAL slow_query_log_file = '/path/filename'; A sample line in the log file:

Elastic Search - Getting started (Draft)

Install (for test) I used Docker image for test purpose. https://www.elastic.co/guide/en/elasticsearch/reference/current/starting-elasticsearch.html docker run -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.12.1 Check the status $ curl localhost:9200 { "name" : "cfd8f0ec08e2", "cluster_name" : "docker-cluster", "cluster_uuid" : "f5fi-57iSVWngx0slmijPA", "version" : { "number" : "7.12.1", "build_flavor" : "default", "build_type" : "docker", "build_hash" : "3186837139b9c6b6d23c3200870651f10d3343b7", "build_date" : "2021-04-20T20:56:39.040728659Z", "build_snapshot" : false, "lucene_version" : "8.8.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } Before setting - concepts https://www.