LMJW Blog My notes.

OOP design notes

Decomposition & Generalization Association Loosely coupled relationship between two objects. Below are the code representation. UML represents this with solid line. public class Student{ public void play(Sport sport){ ... } } public class Wine{ public void pair( food){ ... } } Aggregation More like has a relationship where a whole has parts that belong to it. The code example is below. Uml represents with empty diamond. Diamond is on the class that has other class. public class Airliner{ private ArrayList<CrewMember> crew; public Airliner(){ crew = new ArrayList<CrewMember>(); } public void add(CrewMember crewMember) { ... } } public class PetStore{ private ArrayList<Pet> pets; public PetStore(){ pets = new ArrayList<Pet>(); } public void add(Pet pet){ .

Simple prost use guid

Simple tonic/prost example A simple tonic repo setup Using gRPC usually requires both client & server to have same protobuf definition. Client and server usually are not defined in the same repository. We can use a separate git repository to store the protobuf definition, and using the git submodule to include the protobuf definition in the corresponding client and server. Check sample repo to see how to setup A simple prost example Sometime you only want to use protobuf to do serializing and deserializing the message, nothing else. In this case, you will need to use prost only. Here is a simplest example of how to do that.

Painless key mapping on windows

Recently, I start to using windows for my personal project. One thing I hate about is the keyboard mappings. I want to basically do the following mappings 1 Caps lock key -> Left Ctrl key 2 Left Alt key -> Left Ctrl key 3 Left Windows key -> Left Alt key I was using the . The first two key mapping works fine, however, the third mapping has the problem. For example, “Win+W” should suppose to map to “Alt+W” which corresponding to the “Copy” in emacs, however, it opens the “Pen” app in the Windows. I did some research, and found another tool, which called the AutoHotKey.

Learning OS dev notes

Notes about learning OS dev: [1] A minimal kernel Below are list of references that I used to learn A minimal Multiboot Kernel HelloOS What is the minimal setting/configuration we need to have so we can boot a minimal kernel? Assuming we are using GRUB boot loader, it seems to me we need to have 4 files to be able to boot a minimal kernel. … ├── Makefile └── src └── arch └── x86_64 ├── multiboot_header.asm ├── boot.asm ├── linker.ld └── grub.cfg Let’s go through these files one by one. multiboot_header.asm To know what is this, we need to know how boot works.

Data Oriented Design

Data Oriented Design Check out the video. This explains the AOS and SOA very well. data orientied design The following code is a common pattern in Object oriented programming. struct Entity{ v3 postion, v3 velocity, int flag, virtual void update() } struct Player: public Entity{ float life, float mana, void update() override; } struct Monster: public Entity{ float life, void update() override; } sturct Door: public Entity{ bool current_status, float open_target, void update(); } There are few problems with this approach: Memory allocation. In this objected orientied approach, because we inherited Entity objects and added some fields in child object, the size of the new Object can have different sizes.

Intro to deep learning notes

This is a note for MIT 6.S191 course link course 1. Intro to deep learning The Perceptron: Forward Propagation Single layer neural network with tensorflow: from tf.keras.layers import * inputs = Inputs(m) hidden = Dense(d1)(inputs) outputs = Dense(d2)(hidden) model = Model(inputs, outputs) This four lines of code computes the single layer NN. Deep Neural Network More hidden layers Applying Neural Networks Quantifying Loss Compare Predicted loss vs actual loss Minimize loss Different loss functions Binary cross entropy loss loss = tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits( model.y, model.pred )) Mean squared error loss loss = tf.

A explanation of Open ssl certification

Open SSL certificate authority Statement: This is just a study notes in order to understand the Open SSL and some relating concepts. A lot of contents in this article are copied from Jamie Nguyen’s blog OpenSSL Certificate Authority Article summary(without Certificate revocation lists) The following graph summarizes the relationship between different keys and certificates. Certificate authority A certificate authority (CA) is an entity that signs digital certificates. Many websites need to let their customers know that the connection is secure, so they pay an internationally trusted CA (eg, VeriSign, DigiCert) to sign a certificate for their domain. In some cases it may make more sense to act as your own CA, rather than paying a CA like DigiCert.

A python example of realizing secure grpc communication

A python example of realizing secure grpc communication Useful links and references: Here are some links that I found it can be helpful when I was trying to work out how to setup the python ssl communication. Secure gRPC with TLS/SSL, This is golang implementation certstrap, a convienient tool to generate openssl keys and certificate gRPC authentication, the official guide of grpc grpcio, python package, the source code and official document of grpc python grpc golang ssl example, another golang example of ssl communication What is the difference between .pem , .csr , .key and .crt?, a stackexchange question which explains the concepts and differences of different types of files

A simple example of using docker container to realize the grpc client and server communication

First, build a docker container that contains all required packages. In this example, I choose ubuntu:bionic as the basic image, and I installed other packages onto it. FROM ubuntu:bionic RUN apt-get update RUN apt-get install python3 -y RUN apt-get install python3-pip -y RUN pip3 install grpcio ADD app /app/ EXPOSE 22222 The Dockerfile is shown above. In the app file, it contains 4 files. They are: client.py, server.py, test_pb2.py, test_pb2_grpc.py test_pb2.py and test_pb2_grpc.py is generated by compiling the test.protofile. The content for test.proto is shown below. syntax = "proto3"; package lmjwtest; // service, encode a plain text service EncodeService { // request a service of encode rpc GetEncode(plaintext) returns (encodetext) {} } message plaintext { string pttransactionID = 1; string ptproperties = 2; string ptsenderID = 3; } message encodetext { string enctransactionID = 1; string encproperties = 2; string encsenderID = 3; } By using the grpcio-tools to compile the test.

Kubernete's tutorial notes

#Some concepts of Kubernetes Clusters Kubernetes cluster(KC) can be analogy to the conventional computational cluster, which includes many computers and to work as a single unit. application runs on the KC needs to be containerized. the program organizing the KC, namely Kubernete, manage the deployment and make containerized application run in KC in a more efficient way. Kubernetes cluster structure Master ( act as a manager): coordinate the cluster Nodes (act as worker, the job of work is to run the containerize application) Master responsibilities : coordinate activities in cluster scheduling application maintaining application states scaling application rolling new updates Node(worker) definition of Node: A node can be a VM or a physical computer that serves as a worker machine in a KC.