Docker Cheat sheet, a general cheat sheet for all use case

Docker general Help - docker COMMAND --help This is for each command’s detail For example, docker run --help TL;DR docker run <image> - to initialize a new container docker start <container_name> start running the “stopped” container docker stop <container_name> docker run - Initialize a container Run a command in a new container Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Basic form to initialize a container, or to run a command...

January 8, 2023 · 9 min · Derry

Spring Boot Controller Service Repository

Spring RESTful service Laur Spilca Youtube Tutorial series spring docs Spring Restful service is a popular backend application. The architecture usually is made up with 3 layers: Controller, Service, and Repository. Configuration setup @SpringBootApplication - define the app root The start point of program It’s with @ComponentScan - tell spring to create beans in which the classes have been annotated with. Spring RESTful Service architecture Spring RESTful service usually has this architecture....

January 1, 2023 · 7 min · Derry

Java Abstract Class and how to use it? When we combine it with interface?

Java abstract class An abstract class is like a structure of data. However, unlike interface, it can define methods and attribute. You can view it as an enforced blueprint for an object. You cannot initiate an object from it but from its sub-classes. An abstract class is: It cannot be instantiated It can contain constructor and object fields. Contains abstract method (0 to many), and concrete methods Its subclasses must override its abstract method An abstract class example:...

December 11, 2022 · 3 min · Derry

Java IO package - What is RandomAccessFile and how to use it

RandomAccessFile This allows you to read from it or write to it as you please. You can replace the content of the file. This cannot achieve by FileInputStream or FileOutputStream. Create a RandomAccessFile object RandomAccessFile file = new RandomAccessFile("file.txt", "rw"); Mode Description r Read mode. Calling write methods will result in an IOException. rw Read and write mode rwd Read and write mode - synchronously. All updates to file content is written to the disk synchronously....

December 4, 2022 · 1 min · Derry

Java - static Keyword

static In simple words: static means the variable or methods that assigned to are belonging to the class, not the object. Therefore, there’s only one copy of the variable/method in the memory. When create an object where all instance variables aren’t static, every object will own its memory space, and its own copy of value. Suppose we have a ball class: class Ball{ double radius; final double PI = 3.14159; } We create 2 Ball objects, each Ball object will have its own instance variables in the memory...

April 18, 2022 · 5 min · Derry