Posts

Showing posts from December, 2019

how to use Curl cmd

curl -X POST -H "x-api-key: xscsss" -F "file=@/path/to/OLSTXNRF_tcbs_20191226_01.TXT" https://host:2189/ftpdata/tcbs/user_input/OLSTXNRF_tcbs_20191226_01.TXT Method: POST x-api-key: header -F chỉ ra là file file: là filename @/path/to/OLSTXNRF_tcbs_20191226_01.TXT    : Đường dân tới file, bao gồm cả @ https://host:2189/ftpdata/tcbs/user_input/OLSTXNRF_tcbs_20191226_01.TXT   : là url api  ------------------------------------------------------------------------------------ pull a GET request from a url or uri curl http://www.example.com/index.html pull and save response to a file curl http://www.example.com/index.html -o out.exxxx  -------------------------------------------------------------------------------------- post data to url  curl -d '{"id":9,"name":"baeldung"}' -H 'Content-Type: application/json'    http://localhost:8082/spring-rest/foos/new pass a file containing ...

How to start, stop & restart services in ubunt

List all service systemctl or service --status-all Start a service systemctl start <service-name> or service <service-name> start Stop a service systemctl stop <service-name> or service <service-name> stop Restart a service systemctl restart <service-name> or service <service-name> restart Check the status of a service systemctl status <service-name> or service <service-name> status

how to use 'alias' in linux

Many a times, you might need to create new commands from existing commands. Sometimes, existing commands have complex options to remember. In such cases, we can create new commands as follows: $ alias ll='ls –l' $ alias copy='cp –rf' To list all declared aliases, use the following command: $ alias To remove an alias, use the following command: $ unalias copy

how to use git config

$ git config --global alias.co checkout $ git config --global alias.br branch $ git config --global alias.ci commit $ git config --global alias.st status Dùng để tạo cú pháp ngắn gọn cho câu lệnh git Ví dụ $ git config --global alias.unstage 'reset HEAD --' thì 2 câu lệnh duwois là tương đương $ git unstage fileA $ git reset HEAD fileA

how to use git tag

git tag -a v1.4 -m 'my version 1.4' Dungf để tạo một version tag git tag Dùng để show list of tag git show v1.4 Dùng để show chi tiết tag

how to use git reset

git reset Lệnh này sẽ move tất cả file ở trong vùng index(staging) sang vùng working git reset fileName Lệnh này sẽ move fileName ở trong vùng index(staging) sang vùng working Đây là cách để bạn revert sau khi dùng lệnh git add --------------------------------------------------- Giả sử bạn commit 1 thay đổi , nhưng bạn thấy thay đổi này k ổn vậy cần phải bổ sung thêm, Thì bạn có thể sửa lại file rồi dùng lệnh git commit -amend  Lệnh này sẽ gộp last commit với commit vừa rồi tạo thành một commit --> bạn có thể push ----Cách 2 Bạn nghĩ rằng tôi sẽ xóa commit vừa rồi và làm lại nó Bạn có thể dùng cách này git reset --soft id_commit Lúc này nó giống như là commit cuối đã được xóa và vùng index vẫn giữ nguyên nội dung của commit cuối, hiểu đơn giản là giờ bạn đang có thay đổi đó ở index rồi, bạn thoải mái sửa và add lại rồi commit. Đây cũng là cách hay dùng nhất nè git reset --mixed id_commit hoặc git reset id_commit  Bằng cách này thì comm...

how to use git branch --merged and git branch --no-merged

Bạn đang ở nhánh master Để xem các branch đã merger vào master thì dùng git branch --merged   iss53 * master Còn để xem các branch chưa merge vào master thì dùng git branch --no-merged

how to use git merge

Nếu muốn merge một nhánh A vào nhánh B Thì cần phải checkout về nhánh B trước đã Dùng lệnh git checkout B Sau đó dùng lệnh git merge A ------------------------------------------------------------------- Tình huống thực tế là bạn có một nhánh master Và cần hotfix một lỗi issue-cacheerror khi đó bạn gần làm là Di chuyển về nhánh master với lệnh git checkout master  Sau đó dùng lệnh dưới để tạo một nhánh mới từ *Head trên master và vào nhánh đó git checkout -b issue-cacheerror  Như vậy bạn đã ở nhánh hotfix rồi, bạn sửa và test ok Sau đó bạn sẽ về lại nhánh master và dùng lệnh sau git checkout master git merge issue-cacheerror Done

how to push code from feature to develop

Git resolve conflict dev Khi bạn đang ở nhánh feature/xxx code và đẩy lên dev. Vấn đề là khi đẩy lên dev thì khả năng cao là code sẽ bị conflict vậy bạn cần phải resolve trước khi push. Bạn cần làm là Switch  nhánh feature git pull origin develop Lấy code mới nhất rồi resolve và commit lại và push là ok

how to use git stash

Git stash Dùng để lưu một bản sao trạng thái thay đổi hiện tại Git stash list  dùng để view danh sách các stash git stash apply  nó sẽ apply stash{0} nhưng k xóa stash đó đi git stash pop  nó sẽ apply stash{0} và xóa stash đi git stash drop  sẽ k apply nhưng sẽ xóa stash{0} git stash apply stash@{1} sẽ k xóa stash, và apply stash{1} Nhưng tất cả apply trên sẽ chỉ áp dụng cho tại vùng Working, không áp vào vùng Staging Để stassh vào cả vùng staging thì thêm option --index git stash apply --index

how to use git checkout -b

Để tạo một  local branch mới và checkout tới remote đó luôn thì dùng $ git checkout -b iss53 Switched to a new branch 'iss53' ---------------------------------- This is shorthand for: $ git branch iss53 $ git checkout iss53

how to use git checkout

git checkout fileName Lấy file trong index để copy vào working place, nhưng vẫn giữ file trong index, lệnh này khác lệnh git reset filename vì reset sẽ move file từ index về working git checkout HEAD fileName Lấy file trong commited để copy vào working place, và xóa trong index những thay đổi của file đó

how to use git diff

git diff Dùng để so sánh file trong vùng Working và vùng Staging git diff --cached  dùng lệnh này để so sánh sự thay đổi của file trong Staging và trong vùng Commited git diff  HEAD  so sánh file working và Commited git diff  id_commit1 id_commit2 Dùng để show diff giữa 2 commit khác nhau git diff  id_commit1 id_commit2   fileName Dùng để show diff giữa 2 commit khác nhau của fileName git diff branch1 branch2 ./diff_test.txt Dùng để so sánh 2 file ở hai branch khác nhau git diff --name-status SHA1 SHA2 [tên file] cho thấy status của các file đã thay đổi từ 2 version trên

delete branch in git

To delete a local branch git branch -d yourBranchName --------- To force delete a local branch git branch -D yourLocalBranch -------------- To delete a remote branch git push origin --delete remoteBranchName

How to use chmod in linux

Image
user (u),  group (g),  other (o) all (a)  The permission r for read,  w for write and  x for execute For example: Change mode a file as below, that group has not write, execute permission, the other is too chmod go-wx filename Example 1: The file should have read, write and execute permissions to user, read and execute permissions to group and read, and execute permissions to others. read, write and execute permissions to user =7 read and execute permissions to group =5 read and execute permissions to others=5 So total permissions will be 755 chmod 755 filename Example 2: Providing write access to a user chmod u+w filename Example 3: Adding write permissions to a group chmod g+w filename Example 4: Adding executable permissions to others chmod o+x filename Example 5: Adding executable and write permissions to all chmod a+wx filename Example 6: Replicating user permissions to a group chmod u=g filename ...

Install font in ubuntu

https://askubuntu.com/questions/3697/how-do-i-install-fonts https://itsfoss.com/install-fonts-ubuntu/ https://askubuntu.com/questions/386160/how-to-install-multiple-ttf-fonts-for-system-wide-usage

install oci8 in ubuntu

Development (Ubuntu) Download ( https://www.oracle.com/technetwork/database/database-technologies/instant-client/overview/index.html )[Oracle Instant Client] and ( https://www.oracle.com/technetwork/database/database-technologies/instant-client/overview/index.html )[Oracle Instant Client SDK Package] to your  ~/Downloads  directory, then install them: mkdir -p ~/apps/oracle mv ~/Downloads/instantclient-* ~/apps/oracle cd ~/apps/oracle unzip instantclient-basic-linux.x64-18.3.0.0.0dbru.zip unzip instantclient-sdk-linux.x64-18.3.0.0.0dbru.zip Create the config file  oci8.pc vim ~/apps/oracle/oci8.pc with the content as file  conf/oci8.pc  (change  /opt/oracle/instantclient_18_3  to  /home/<your_username>/apps/oracle/instantclient_18_3 ) Add to the end of your  .profile  or  .bashrc export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/<your_username>/apps/oracle/instantclient_18_3 export PKG_CONFIG_PATH=$PKG_CONFIG...

Dockerfile tutorial

FROM golang:latest Lệnh này là khai báo base image được dùng để tạo new image. golang: tên base image latest: version của base image, bạn cũng có thể dùng sha256 để xác định rõ một version golang@sha256 RUN mkdir /app câu lệnh này dùng để thực thi một câu lệnh cmd trên new image, tương tư như câu lệnh trên terminal thông thường Tạo một layer trong new image Câu lệnh này đượng thực thi trong vòng đời "build time" nghĩa là build new image ADD      .       /app/ Lệnh này dùng để copy thư mục hiện tại (.)  vào thư mục app trên new image WORKDIR /app câu lệnh này tương tự như câu lệnh cd trong terminal, ý là chỉ con trỏ tới thư mục working /app RUN go build -o main .  Lệnh này tương tự như bạn chạy câu lệnh trong terminal là "go build -o main" CMD ["/app/main"] lệnh này tương tự như lệnh RUN là chạy một câu lệnh nhưng nó cho phép bạn truyền thêm tham số Lệnh này là lệnh running time trong vòng đời. Nó chỉ thực thi khi ảnh đã...

Docker push image to docker hub

https://hub.docker.com/ Bạn cần tạo tài khoản ở trang web docker registry bên trên với username và password ví dụ là bonh/12345678 ---------------- Sau đó đăng nhập trong docker cli với cú pháp docker login --------------- Bước tiếp theo là bạn cần có 1 cái ảnh là:  demo_image:latest Bạn muốn đẩy ảnh này lên thì cần phải commit trước Muốn commit được thì cần phải có một containner đang chạy với ảnh đó Bạn chạy với local 1 containner trên ảnh đó với tên là : abc_xxx dùng lệnh: docker commit abc_xxx bonh/demo_image:tag_name với tag_name là tag bạn tự đặt có thể k cần trùng với latest --------------- Sau khi có tag_name rồi thì bạn dùng lệnh docker push bonh/demo_image:tag_name -------------- https://hub.docker.com/repositories check image đã đẩy lên ------------- để kéo về thì bạn dùng lệnh docker pull bonh/demo_image:tag_name

/etc/enviroment

This file is used for setting up enviroment variable in linux Such as JAVA_HOME, MAVEN_HOME

maven-jar-plugin

<plugin> <!-- Build an executable JAR --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.1.0</version> <configuration> <archive> <manifest> <!-- <addClasspath>true</addClasspath>--> <!-- <classpathPrefix>lib/</classpathPrefix>--> <mainClass>main.Application</mainClass> </manifest> </archive> </configuration> </plugin> Nếu bạn có một file .jar hoặc .war và dùng câu lệnh java -jar app.jar mà không thực thi được chương trình thì khi đó bạn cần add plugin bên trên vào file pom.xml và build lại toàn bộ suorce code. Lúc này trình maven sẽ chỉ rõ fil...

maven-compiler-plugin

<build> <plugins> <plugin> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-compiler-plugin </artifactId> <version> 3.8.0 </version> <configuration> <source> 9 </source> <target> 9 </target> </configuration> </plugin> </plugins> </build> Khi bạn tạo một Maven project để thực hiện được các lệnh như mvn clean : dùng để xóa toàn bộ các file java.class và làm sạch thư mục target khi build mvn compile : dùng để compile toàn bộ file .java trong ứng dụng thành file .class mvn install : dùng để build toàn bộ tập file .class thành .jar hoặc .war thành file có thể thực thi được --------------- trong file trên chúng ta để ý tới version 3.0.8 đây chỉ là version của plugin, nó giống như version của app của bạn vậy source 9: nghĩa là code của ...