Coding Spirit

一位程序员,比较帅的那种

0%

SSH connection will automatically drop due to timeout if there is no operation for a period. To keep connection alive, we can config ssh client to send a keepalive periodically. In ~/.ssh/config, there is a parameter for this:

1
ServerAliveInterval 60

If we set this value to 60, SSH client will send a keepalive every 60 seconds.

Last week when I was trying to run tshark in a Docker container to capture http packets, tshark reported following error even with root user:

1
tshark: Couldn't run /usr/bin/dumpcap in child process: Operation not permitted

After searching, to access dumcap, we need to add --cap-add options when start container, then add user into wireshark group:

1
2
docker run --cap-add=NET_RAW --cap-add=NET_ADMIN $IMAGE
usermod -a -G wireshark $USER

Jenkins is running on port 8080 by default, thus user need to manually add :8080 when access Jenkins. If we make it running on port 80(default http port), user will no longer need to type port number manually.

Read more »

CMake will try to check compiler is working or not if project language was set to C/CXX. However, sometimes we just want to skip this test…

Read more »

With OAuth2 Token Authentication

1
curl -H "Authorization: token <OAUTH-TOKEN>" https://api.github.com

Create A Release And Add An Artifact

1
2
3
4
5
6
7
8
9
10
11
12
# Create a new release and get upload url
upload_url=$(curl -s -H "Authorization: token $TOKEN" \
-d '{"tag_name":"'"$ARTIFACTS_BASE_NAME"'", "name":"'"$ARTIFACTS_BASE_NAME"'", "body":"'"$ARTIFACTS_BASE_NAME"'", "target_commitish":"'"$TARGET_BRANCH"'"}' \
"https://api.github.com/repos/$REPO/$TARGET_BRANCH" | jq -r '.upload_url')

upload_url="${upload_url%\{*}"

# Upload a tarball
curl -s -H "Authorization: token $TOKEN" \
-H "Content-Type: application/x-gzip" \
--data-binary @$ARTIFACTS_BASE_NAME.tar.gz \
"$upload_url?name=$ARTIFACTS_BASE_NAME.tar.gz&label=$ARTIFACTS_BASE_NAME.tar.gz"

Yesterday successfully cross compiled curl with mbedTLS, but there was an error when trying to access a https link:

1
SSL certificate problem: unable to get local issuer certificate

To fix it, download CA certificate to local machine and export environment variable CURL_CA_BUNDLE:

1
2
wget https://curl.haxx.se/ca/cacert.pem
export CURL_CA_BUNDLE=<path of cacert.pem>