January 3, 2022

AWS Cost EC2-Other

 It usually consists the following cost:

1. EBS volumes
2. Nat Gateway
3. EBS snapshots
4. Idle Elastic IPs
5. Data transfer 

 

December 8, 2021

macos brew install java11

 brew install java11

sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk


August 31, 2020

openssl ssl version number interpretation


in file: usr/include/openssl/opensslv.h     of openssl source code.                                                                                                         

/*-
 * Numeric release version identifier:
 * MNNFFPPS: major minor fix patch status
 * The status nibble has one of the values 0 for development, 1 to e for betas
 * 1 to 14, and f for release.  The patch level is exactly that.
 * For example:
 * 0.9.3-dev      0x00903000
 * 0.9.3-beta1    0x00903001
 * 0.9.3-beta2-dev 0x00903002
 * 0.9.3-beta2    0x00903002 (same as ...beta2-dev)
 * 0.9.3          0x0090300f
 * 0.9.3a         0x0090301f
 * 0.9.4          0x0090400f
 * 1.2.3z         0x102031af


To get the above version number, you can all the following function: 
#include <openssl/opensslv.h>
#include <openssl/crypto.h>
void ssl_get_version(void) {
    printf ("Using OpenSSL version %u\n", OpenSSL_version_num());
}

August 16, 2020

ffmpeg command for generating Amazon Ads video

 ffmpeg -i videoSharingFinalOutput.MOV -profile:v main -r 25 -vf scale=1280:720 output.mp4

July 21, 2020

Golang short variable declaration gotcha

Golang allows short variable declaration in the form of i:=0, which defines a integer variable i. Golang also allows multi-variable short declaration, e.g.

i,j := 0,1

In this case, as long as there is one new variable on the left side, for example, i, the compiler would be happy. However, if j is not defined in the SAME BLOCK SCOPE, a new j will be created! Most times this is not what you want. Got to be very careful with that. A full example:

func test(){
    j:=1;
    if j==1 {
        i,j:=2,3
    }
    fmt.Println(j) // j is still 1!!
}

June 26, 2020

Golang range gotcha

In golang, when you range through an array of elements as in the following:

// THIS CODE IS WRONG; DO NOT USE THIS
for i,v := range elements {
    go do_something(v)
}

In the above example, the value of v may change while do_something tries to used it. This is a race condition and will definitely cause problem. To fix this, one should use elements[i] instead;