November 21, 2020
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
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;
June 12, 2020
Vim typescript jump-to-definition
- Use vim 8.1 or newer (in older version of vim,
tagstack
doesn’t work with the solution below) - Install ALE https://github.com/dense-analysis/ale
- bind
Ctrl-]
toALEGoToDefinition
using the following snippet of code
function ALELSPMappings()
let l:lsp_found=0
for l:linter in ale#linter#Get(&filetype) | if !empty(l:linter.lsp) | let l:lsp_found=1 | endif | endfor
if (l:lsp_found)
nnoremap <buffer> <C-]> :ALEGoToDefinition<CR>
nnoremap <buffer> <C-^> :ALEFindReferences<CR>
else
silent! unmap <buffer> <C-]>
silent! unmap <buffer> <C-^>
endif
endfunction
autocmd BufRead,FileType * call ALELSPMappings()
- install
tsserver
if you have not done so usingnpm
- Done.
June 11, 2020
AWS API Gateway Wildcard Path
In API Gateway configuration, typically one specifies an complete API Path, such as /api/v1/fruits/list
. Sometimes, it may be necessary to specify a wildcard path that includes multiple complete API paths. This is how you can do it.
- Use curly brackets. Specify
/api/v1/fruits/{action}
to allow any action to be accepted. Action can be any valid URL path segment, but it only covers one depth. It does not cover deeper URL likeapi/v1/fruits/list/all
. - To cover all sub-links, use
{proxy+}
. The+
sign tells API Gateway to accept all sub-links. - Note that you need a separate API for the root path itself, in this case
/api/v1/fruits
needs its own API. It’s possible to use /api/v1/fruits/{action?} to cover the root path. Needs to be verified since it’s not in the documentation. - In GoLang, the wildcard value is passed to the Lambda handler in a string-to-string map named PathParameters.
PathParameters:map[string]string{"id":"234"}
See more at https://aws.amazon.com/blogs/aws/api-gateway-update-new-features-simplify-api-development/
May 4, 2020
gitconfig
[user]
name = MY NAME
email = MY EMAIL
[core]
editor = vim
whitespace = cr-at-eol
[merge]
tool = vimdiff
[alias]
vimdiff = difftool
st = status -sb
ci = commit -a
br = branch
co = checkout
df = diff --ignore-space-at-eol -w -b
dc = diff --cached
dl = diff --name-only
last = log -1 HEAD --stat
lg = log --stat
lb = log --graph --oneline --decorate --date=short --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=relative master..
tr = log --graph --oneline --decorate --all --date=short --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=relative
tr1 = log --graph --oneline --decorate --date=short --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s'
h = log --color --date=short --pretty=format:\"%C(yellow)%h%C(reset) %s%C(bold red)%d%C(reset) %C(green)%ad%C(reset) %C(blue)[%an]%C(reset)\" --decorate
who = shortlog -s --
out = log origin/master..master
in = "!git fetch; git log master..origin/master"
unstage = reset HEAD --
root="rev-parse --show-toplevel"
[diff]
renames = copy
tool = vimdiff
[difftool "vimdiff"]
cmd = "vim -d" "$LOCAL" "$REMOTE"
prompt = false
[push]
default = simple
[sendpack]
sideband = false
[pager]
status = true
[fetch]
prune = true