Posts

Showing posts from July, 2020

Hiểu về byte và rune trong Golang

tại sao Golang lại có 2 kiểu dữ liệu byte và rune // byte is an alias for uint8 and is equivalent to uint8 in all ways. It is // used, by convention, to distinguish byte values from 8-bit unsigned // integer values. type byte = uint8 // rune is an alias for int32 and is equivalent to int32 in all ways. It is // used, by convention, to distinguish character values from integer values. type rune = int32 Thực ra byte và rune là 2 kiểu alias của uint8 và int32 byte nó đại diện cho các ký tự không dấu rune nó đại diện cho các ký tự unicode nên nó có khoảng rộng hơn byte Ví dụ bạn có 2 chuỗi string như sau s1 := "a123acb" s2 := "a123acbaHôm nay quá đẹp" arr1 := [] byte ( s1 ) fmt . Printf ( " %v \n " , arr1 ) arr2 := [] rune ( s2 ) fmt . Printf ( " %v " , arr2 ) Như vậy khi bạn ép kiểu thì thao tác sẽ không bị mất dữ liệu

Format types in golang

https://gobyexample.com/string-formatting %s  dùng để format cho String:  fmt . Printf ( "%s\n" , "\"string\"" ) %c dùng để format 1 số nguyên về kiểu ký tự fmt . Printf ( "%c\n" , 33 ) %v dùng để format một struct, hoặc số, hoặc boolean, hoặc con trỏ về đúng kiểu giá trị của nó %T dùng để xác đinh type của kiểu dữ liệu fmt . Printf ( " %T\n " , p ) fmt . Printf ( " %t\n " , true ) %d dùng để in giá trị số nguyên %f dùng để in số thực fmt . Printf ( " %.2f\n " , 78.123123 )

Design Pattern in golang

https://golangbyexample.com/golang-object-pool/

how to uninstall a software in ubuntu

sudo snap remove skype  or Uninstall mahjongg  To remove just mahjongg package itself from Ubuntu 16.04 (Xenial Xerus) execute on terminal:  sudo apt-get remove mahjongg  Uninstall mahjongg and it's dependent packages  To remove the mahjongg package and any other dependant package which are no longer needed from Ubuntu Xenial.  sudo apt-get autoremove mahjongg  Purging mahjongg  If you also want to delete configuration and/or data files of mahjongg from Ubuntu Xenial then this will work:  sudo apt-get purge mahjongg  To delete configuration and/or data files of mahjongg and it's dependencies from Ubuntu Xenial then execute:  sudo apt-get autoremove --purge mahjongg

How to make bootable usb from terminal in linux os

https://askubuntu.com/questions/372607/how-to-create-a-bootable-ubuntu-usb-flash-drive-from-terminal https://vitux.com/how-to-create-a-bootable-usb-stick-from-the-ubuntu-terminal/ Step1  To recognize your USB drive's location on your disk. Let's run this command lsblk and you will see this  sda      8:0    0 119.2G  0 disk  ├─sda1   8:1    0  55.9G  0 part / ├─sda2   8:2    0     1K  0 part  ├─sda5   8:5    0   3.7G  0 part [SWAP] └─sda6   8:6    0  59.7G  0 part /home sdb      8:16   1   7.3G  0 disk  └─sdb1   8:17   1   7.3G  0 part  ==> sdb1 Step2: sudo umount /dev/sdb1 Step 3  sudo dd bs=4M if=path/to/input.iso of=/dev/sd<?> conv=fdatasync  status=progress  

how to create bootable usb on linux os

https://elementary.io/docs/installation#installation https://unetbootin.github.io/linux_download.html

Tạo một bài viết phân tích yếu điểm của các hệ thống dùng SMS để xác thực 1 lần và cách cải tiến hệ thống để bảo mật hơn

Issues trong khi build docker image

failed to export image: failed to set parent sha256:1524fb5245903585bbe27769969c45f569583cc0f9b37c3e7d1c26f058bc0b02: unknown parent image ID sha256:1524fb5245903585bbe27769969c45f569583cc0f9b37c3e7d1c26f058bc0b02 rất có thể là do bạn đã xóa mất một layer image nào đó rồi

Function vs Procedure trong Oracle database

Functions A function is compiled and executed every time whenever it is called. A function must return a value and cannot modify the data received as parameters Stored Procedures Stored Procedures are pre-compiled objects which are compiled for the first time and its compiled format is saved, which executes (compiled code) whenever it is called. For more about a stored procedure, please refer to the article  Different types of Stored Procedure .

Procedure demo

--generate checksum for all records in transaction history --remember to change checksumKey DECLARE checksumKey varchar2 ( 100 ) : = 'Tcbs@20022020' ; rawData varchar2 ( 1000 ) : = '' ; newchecksum varchar2 ( 1000 ); BEGIN DBMS_OUTPUT . PUT_LINE ( 'INFO: Workflow initiated' ); FOR txh IN ( SELECT * FROM IXU_TRANSACTION_HISTORY WHERE CAMPAIGN_ID = 2006 ORDER BY ID DESC ) LOOP rawData : = concat ( ':' , txh . HISTORY_KEY ); IF txh . EXPIRED_DATE IS NULL THEN rawData : = concat ( '' , rawData ); rawData : = concat ( ':' , rawData ); ELSE rawData : = concat ( TO_CHAR ( txh . EXPIRED_DATE , 'YYYY-MM-DD' ), rawData ); rawData : = concat ( ':' , rawData ); END IF ; rawData : = concat ( to_char ( txh . OUTSTANDING , 'FM99999999999999990.00' ), rawData ); rawData : = concat ( ':' , rawData ); rawData : = concat ( to_char ( ...

How to create procedure in oracle

CREATE INDEX temp_tcbsid_IXU_TRANSACTION_HISTORY ON IXU_TRANSACTION_HISTORY ( TCBSID ); CREATE INDEX temp_tcbsid_IXU_GENERAL_LEDGER ON IXU_GENERAL_LEDGER ( TCBSID ); create procedure updateCurrentBalanceExactly ( tcbsid_in IN varchar2 , redeemablePoint_in IN number , rankingPoint_in IN number ) is begin update IXU_GENERAL_LEDGER set RANKING_POINT = rankingPoint_in , REDEEMABLE_POINT = redeemablePoint_in where TCBSID = tcbsid_in ; -- caculate checksum here -- commit; end ; create procedure updateHistoryByID ( id_in IN number , outstanding_in IN number ) is begin update IXU_TRANSACTION_HISTORY set OUTSTANDING = outstanding_in where ID = id_in ; -- caculate checksum here -- commit; end ; create procedure arrangeHistoryByIssueDateAndGlIDExactly ( tcbsid_in IN varchar2 , award_type_in IN varchar2 ) is initBalance number ; begin initBalance = 0 ; for txHistory in...

How to write procedure in oracle database

Declare procedure verifyPointOutStandingByTcbsId ( tcbsid_in IN varchar2 ) is sumOfCreditPointRedem number ; sumOfDebitPointRedem number ; resultRedem number ; currentBalanceRedem number ; sumOfCreditPointRank number ; sumOfDebitPointRank number ; resultRank number ; currentBalanceRank number ; begin -- dbms_output.PUT_LINE('verifying this tcbsid: ' || tcbsid_in); select sum ( POINT ) into sumOfDebitPointRedem from IXU_TRANSACTION_HISTORY where ACTION = 'Debit' and AWARD_TYPE = 'Redeemable' and TCBSID = tcbsid_in ; select sum ( POINT ) into sumOfDebitPointRank from IXU_TRANSACTION_HISTORY where ACTION = 'Debit' and AWARD_TYPE = 'Ranking' and TCBSID = tcbsid_in ; select sum ( POINT ) into sumOfCreditPointRedem from IXU_TRANSACTION_HISTORY where ACTION = 'Credit' and AWARD_TYPE = 'Redeem...

How to create index for column in oracle database

CREATE INDEX temp_tcbsid_IXU_TRANSACTION_HISTORY ON IXU_TRANSACTION_HISTORY ( TCBSID ); CREATE INDEX temp_tcbsid_IXU_GENERAL_LEDGER ON IXU_GENERAL_LEDGER ( TCBSID );

Bài thơ hay về cha mẹ

GỬI CON YÊU DẤU (Bản dịch của Huy Phương) Nếu một mai thấy Cha Mẹ già yếu Hãy thương yêu và thấu hiểu song thân Những lúc ăn Mẹ hay thường vung vãi Hay tự Cha không mặc được áo quần. Hãy nhẫn nại nhớ lại thời thơ ấu Mẹ đã chăm lo tã, áo, bế bồng Bón cho con từng miếng ăn, hớp sữa Cho con nằm trong nệm ấm chăn bông. Cũng có lúc con thường hay trách móc Chuyện nhỏ thôi mà Mẹ nói trăm lần Xưa kia trong nôi giờ con sắp ngủ Chuyện thần tiên Mẹ kể mãi không ngưng. Có những lúc Cha già không muốn tắm Đừng giận Cha mà la mắng nặng lời Ngày còn nhỏ con vẫn thường sợ nước Từng van xin "đừng bắt tắm mẹ ơi" Những lúc Cha không quen xài máy móc, Chỉ cho Cha những hướng dẫn ban đầu. Cha đã dạy cho con trăm nghìn thứ Có khi nào trách móc con đâu? Một ngày nọ khi Mẹ, Cha lú lẫn Khiến cho con mất hứng thú chuyện trò Nếu không phải là niềm vui đối thọai Xin đến gần và hãy lắng tai nghe Có những lúc Mẹ không buồn cầm đũa Đừng ép thêm, gìa có lúc biếng ăn Con cần biết lúc nào Cha thấy đói Lúc nà...

How to extract text from console to log file

sudo journalctl -u odin  -f -n 1000| tee bonh.log đó chính là dùng câu lệnh | tee bonh.log