Using DataDog on your CentOs
1 2 3 4 5 6 7 8 |
DD_AGENT_MAJOR_VERSION=7 DD_API_KEY=<your-key> DD_SITE="datadoghq.eu" bash -c "$(curl -L https://s3.amazonaws.com/dd-agent/scripts/install_script.sh)" sudo nano /etc/datadog-agent/datadog.yaml # uncomment logs_enabled: true sudo systemctl restart datadog-agent sudo mkdir /etc/datadog-agent/conf.d/go.d sudo nano /etc/datadog-agent/conf.d/go.d/conf.yaml # and add contents from the url below |
https://app.datadoghq.eu/logs/onboarding/server https://docs.datadoghq.com/agent/faq/error-restarting-agent-already-listening-on-a-configured-port/ Or, if you want a dockerized version of DataDog agent, and you want to listen to docker logs, you can do this:
1 2 3 4 5 6 7 8 9 10 11 |
docker run -d --name datadog-agent \ -e DD_API_KEY=<DATADOG_API_KEY> \ -e DD_LOGS_ENABLED=true \ -e DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true \ -e DD_CONTAINER_EXCLUDE_LOGS="name:datadog-agent" \ -e DD_SITE="datadoghq.eu" \ -v /var/run/docker.sock:/var/run/docker.sock:ro \ -v /proc/:/host/proc/:ro \ -v /opt/datadog-agent/run:/opt/datadog-agent/run:rw \ -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \ datadog/agent:latest |
More info here — https://docs.datadoghq.com/agent/docker/log/?tab=containerinstallation Then you will see your logs here — https://app.datadoghq.eu/logs
Install go with gvm on MacOS Big Sur
I used to use gvm for this — https://github.com/moovweb/gvm. But initial installation of go from scratch does not work for Big Sur as 1.4 does not have a binary for this OS (this command fails — gvm install go1.4 -B). To use gvm, you can do this: 0. Install gvm — bash <
Use brew cask to install software on MacOS
That’s the way to automate your favorite apps installed on a new machine with one command and a config file. https://github.com/Homebrew/homebrew-cask. You can either install apps manually with a command like brew cask install goland or install all your apps by provided config. One downside is that it has a limited list of apps supported …
Mac fan control
It is interesting to check mac’s CPU/GPU temperature and manage fan speed. You can do it with https://crystalidea.com/macs-fan-control/download
Add all lines from a .env file to environment
zsh:
1 |
zsh ./configs/dev/dev.env|sed 's/#1.*$//g'|grep '^[^#]'|grep -v '^$'|sed 's/^/export /g' |
bash:
1 |
bash ./configs/dev/dev.env|sed 's/#1.*$//g'|grep '^[^#]'|grep -v '^$'|sed 's/^/export /g' |
to output to stdout
1 |
cat ./configs/dev/dev.env|sed 's/#1.*$//g'|grep '^[^#]'|grep -v '^$'|sed 's/^/export /g' |
prepend running a command (did not try it, but something similar):
1 |
env $(cat ./configs/dev/dev.env|sed 's/#.*$//g'|grep '^[^#]'|grep -v '^$'|xargs) |
Complete list of swagger options to protobuf file
Here is an example with many options that help generate proper swagger out of protofile. Original URL — https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/master/examples/internal/proto/examplepb/a_bit_of_everything.proto.
Refactor your code and know it’s completely backward compatible
The idea is to run 2 versions of code on production: 1 (control group) — is your old implementation which will be returned to the end user 2 (the experiment) — is a new implementation which results will be checked against the control group and logged It will be run asynchronously and only for a …
GRPC fallback to Rest API with custom field names
When you generate JSON for Rest API from proto-file, protoc-gen-gofast generates field names for JSON in lowerCamelCase format while most of the Rest APIs use snake_case for that. And if you want to replace some legacy API with your new implementation without breaking backward compatibility, you need to fix it. There could be different ways …
Integration tests with testcontainers-go
Here is the go library that simplifies integration tests with docker containers — https://github.com/testcontainers/testcontainers-go. That’s how you can use it to test sql — https://github.com/testcontainers/testcontainers-go/blob/master/docs/examples/cockroachdb.md. Project documentation — https://golang.testcontainers.org/features/docker_compose/ The idea is to prepare the environment, build your app, then make requests and check the DB state.
Limit kids access to Android
You can use official apps for this: Family Link for Parents — https://play.google.com/store/apps/details?id=com.google.android.apps.kids.familylink and Family Link for Kids — https://play.google.com/store/apps/details?id=com.google.android.apps.kids.familylinkhelper. You need to create a family group, and all your family members will be shown here — https://families.google.com/families and here — https://play.google.com/store/account/family. If you have troubles with some member’s account while trying to add them …