brew install java11
sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
brew install java11
sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
in file: usr/include/openssl/opensslv.h of openssl source code.
ffmpeg -i videoSharingFinalOutput.MOV -profile:v main -r 25 -vf scale=1280:720 output.mp4
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!!
}
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;
tagstack doesn’t work with the solution below)Ctrl-] to ALEGoToDefinition using the following snippet of codefunction 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()
tsserver if you have not done so using npmIn 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.
/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 like api/v1/fruits/list/all.{proxy+}. The + sign tells API Gateway to accept all sub-links./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.PathParameters:map[string]string{"id":"234"}See more at https://aws.amazon.com/blogs/aws/api-gateway-update-new-features-simplify-api-development/
[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
As of 2019/11, AWS charges $0.25 per million connection minutes. That sounds very innocent, but is it?
If your business grows and you have up to 1 million devices that needs to keep connected to an AWS Gateway, the cost, every month, just for the connection fee would be:
$0.25*1440*30*1M/1M = $10,800 per month
In this case, a highly available cluster may be a lot more cost effective.
| Public Subnet | Private Subnet |
|---|---|
| Instances have public IP addresses | Instances do not have public IP address (selectable during instance creation) |
| Route table attached to the subnet has a default route | Route table attached to the subnet has no default route |
| Component | Default VPC | Nondefault VPC |
|---|---|---|
| Internet gateway | Yes | Yes, if you created the VPC using the first or second option in the VPC wizard. Otherwise, you must manually create and attach the internet gateway. |
| Route table with route to internet gateway for IPv4 traffic (0.0.0.0/0) | Yes | Yes, if you created the VPC using the first or second option in the VPC wizard. Otherwise, you must manually create the route table and add the route. |
| Route table with route to internet gateway for IPv6 traffic (::/0) | No | Yes, if you created the VPC using the first or second option in the VPC wizard, and if you specified the option to associate an IPv6 CIDR block with the VPC. Otherwise, you must manually create the route table and add the route. |
| Public IPv4 address automatically assigned to instance launched into subnet | Yes (default subnet) | No (nondefault subnet) |
| IPv6 address automatically assigned to instance launched into subnet | No (default subnet) | No (nondefault subnet) |
geom_bar first to plot a bar graph, and then use coord_polar to convert it to a pie chart. It works, but there is a catch:geom_bar sorts the fill value alphabetically and always put the lowest value one on the top of the bar graph. For example, “apple” would be on the top of “pear”. This becomes a problem if you intend to label the pie chart.dataframe in decreasing order by the fill variable. This way all calculations will be right.df=data.frame(val=c("z","b","c"),c2=c("b","d","f"),Freq=c(5,3,4))
df=df[order(df$val,decreasing=T),]
df$Label <- paste(df$val, paste(round((df$Freq/sum(df$Freq))*100,0),"%",sep=""), sep="-")
p <- ggplot(df,aes(x=1,y=Freq,fill=val))+geom_bar(stat="identity", color = "black")
p1 <- p + coord_polar(theta='y') + theme(axis.ticks=element_blank(),
axis.text.y=element_blank(),
axis.text.x=element_text(colour='black'),
axis.title=element_blank())
p2 <- p1 + scale_y_continuous(labels= df$Label,breaks=cumsum(df$Freq) - df$Freq/ 2)
p3 <- p2 + labs(title=title,fill=legend_title)+theme(plot.title = element_text(hjust = 0.5))
print(p3)
Update on 10/23/2019
This article explains the order issue very clearly:
https://sebastiansauer.github.io/ordering-bars/
In short, the rule for the sort order is:
- if factor, the order of factor levels is used
- if character, an alphabetical order is used
So one can change the factor order to change the plot order.
jq is a very useful tool to process JSON.
The idea of jq is centered on the idea of pipe and data stream.
Note below that a JSON entity is a self-contained and complete JSON object/array.
filter independently.-c (compact) flag to jq to print each stream as one line.. means the entire input data stream.[] moves into the JSON object/array one layer, and splits the data stream into multiple streams, one for each entry in the object or array. For example. {"a":1,"b":2} will broken into two data streams after passing this filter, becoming 1 and 2 respectively. Note that they are the values of the entires and are not valid JSON anymore, which is okay but needs to be noted. The same streaming-splitting will also happen for JSON arrays after passing this filter..["key"] generates one stream from the input stream. The shorthand is .key;, can be used to manually generate multiple streams.[ ] to generate an array, or use { } to generate an object. Note that to generate an object, one has to manually specify the keys, e.g.{"key1":.a, "key2":.b}, or use the shorthand {key1,key2} which is the same as {"key1":.key1,"key2":.key2};( ) can be used to instruct jq which part of the filter to be processed first, but it does not remove/combine/split the data streams.| has lower priority than ,. Therefore, 1,2,3|3 will produce three streams first 1,2,3, respectively, and then pass each stream to the second filter 3, with the end result of 3 streams of 3. If we use (), we can change that order. 1,2,(4|3) will process 4|3 first, generating 3, then processing 1,2,3, generating exact that as 3 streams of outoput. 1|4,2,3 will process 1 first, then passing to 4,2,3 three streams, causing the ending result to be 4,2,3 3 streams.length as $array_length | . to have jq remember a interim value and used in later stages of the filter..|.|.|.|. is the same as .map(x) takes an array as input, and outputs a new array, after running that filter for each element of the input array.select() function can be used to remove undesired streams. [1,2,3] | map(select(. >= 2)) will give you [2,3]if-then-else-end in the filter. Note that the else clause must be there. Sometimes the empty function can help.a//b The alternative operator can also be useful. It outputs a, if a is not false or null, otherwise it outputs b.input_filename can be used to find the input file name.numbers/objects/arrays/etc. to select results from multiple streamsTags: jq
~/.ssh/some_other_key.pub).scp some_other_key.pub intermediate:.ssh/
or, on the intermediate machine:ssh-add -L | grep something_unique > ~/.ssh/some_other_key.pub
You may want to edit the trailing “comment” part of the public key to
better identify the key’s origin/owner/purpose (or attempt to hide the
same).-i or IdentityFile.IdentitiesOnly yes (in .ssh/config or -o) to keep ssh from trying to offer any additional identities from your forwarded agent.%userprofile%\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets
https://www.howtogeek.com/247643/how-to-save-windows-10s-lock-screen-spotlight-images-to-your-hard-drive/
+----------------+
| |
| |
| FREE BUFFER |
| |
| |
+----------------+
| |
| UNSENT BYTES |
| |
+----------------+
| |
| UNACKED BYTES |
| |
+----------------+
Total send buffer size = unacked-bytes + unsent-bytes + free-buffer.
It can be obtained using the SO_SNDBUF socket option.
The buffer size could dynamically change its size as seen needed by the
OS. This works for both Linux and macOS. slen = sizeof(sndbufsiz);
err = getsockopt(sd, SOL_SOCKET, SO_SNDBUF, &sndbufsiz, &slen);
Total inflight bytes = unacked-bytes + unsent-bytes.
It can be obtained using SO_NWRITE socket option on macOS, and SIOCOUTQ ioctl on Linux.int get_socket_used(int sd){
int err;
int used;
#ifdef __APPLE__
socklen_t slen = sizeof(used);
err = getsockopt(sd, SOL_SOCKET, SO_NWRITE, &used,&slen);
if(err < 0) {
perror("getsockopt 2");
exit(1);
}
#else
err = ioctl(sd, SIOCOUTQ, &used);
if(err < 0) {
perror("ioctl SIOCOUTQ");
exit(1);
}
#endif
return used;
}
On macOS, it seems that this can also be obtained using the TCP_INFO struct, but it is a private API.u_int32_t tcpi_snd_sbbytes; /* bytes in snd buffer including data inflight */
TCP_INFO structure, but the result is number of segments, or bytes. On macOS, TCP_INFO seems to contain this infomration (private API).int get_socket_unacked(int sd){
struct tcp_info tcp_info;
socklen_t tcp_info_length = sizeof(tcp_info);
if ( getsockopt(sd, IPPROTO_TCP, TCP_INFO, (void *)&tcp_info, &tcp_info_length ) == 0 ) {
return tcp_info.tcpi_unacked;
}
return 0;
}
//For macOS, use TCP_INFO
u_int64_t tcpi_txunacked __attribute__((aligned(8))); /* current number of bytes not acknowledged */
macOS tcp_info definitiontcpi_notsent_bytes field of the TCP_INFO structure. NOTE that this requires kernel version to be 4.6 or newer. For Android that means Android 8 or newer. On Linux, it can also be obtained using SIOCOUTQNSD ioctl. It’s not clear how to do this on macOS.//defined in /usr/include/linux/sockios.h
int get_socket_unsent(int sd){
int err;
int unsent;
err = ioctl(sd, SIOCOUTQNSD, &unsent);
if(err < 0) {
perror("ioctl SIOCOUTQNSD");
exit(1);
}
return unsent;
}
//OR
int get_socket_unsent(int sd){
struct tcp_info tcp_info;
socklen_t tcp_info_length = sizeof(tcp_info);
if ( getsockopt(sd, IPPROTO_TCP, TCP_INFO, (void *)&tcp_info, &tcp_info_length ) == 0 ) {
return tcp_info.tcpi_notsent_bytes;
}
return 0;
}
Stackoverflow discussion on getting unsent bytesunsent-bytes, when the TCP option TCP_NOTSENT_LOWAT is set. On macOS, kevent() doesn’t report socket as writable until the unsent TCP data drops below speciï¬ed threshold (typically 8 kilobytes).