What is teamlead’s first duty
Sarah Mei «We think awful code is written by awful devs. But in reality, it’s written by reasonable devs in awful circumstances.» (source) So, teamlead is there to improve circumstances.
ORM for go
https://github.com/Masterminds/squirrel Never used it as we always write SQL queries manually. But looks okay for ORM (well, actually a query-builder).
Kubernetes’ cronjobs
That’s what it is — https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ Get all cronjobs in env:
1 |
kubectl --kubeconfig ... --namespace platform -o wide get cronjobs |
Get info on exact cronjob:
1 |
kubectl --kubeconfig ... --namespace platform describe cronjob/smartrouting-cron-import-from-bi |
Get pods with this cronjob:
1 |
kubectl --kubeconfig ... --namespace platform -o wide get pods|grep "rou" |
Get logs of cronjob
1 |
kubectl --kubeconfig ... --namespace platform logs smartrouting-cron-import-from-bi-1555060200-dqg5j |
you can add -f for live updating logs and -p for watching logs of previous pod.
Crontab time format
That’s about it: min hour day/month month day/week Execution time 30 0 1 1,6,12 * — 00:30 Hrs on 1st of Jan, June & Dec. 0 20 * 10 1-5 –8.00 PM every weekday (Mon-Fri) only in Oct. 0 0 1,10,15 * * — midnight on 1st ,10th & 15th of month 5,10 0 10 …
How to make grpc call from shell
1 https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md
1 |
grpc_cli call localhost:7020 ChatAPI.GetChats "external_user:{id:'30594028',type:1}, limit:10, offset:0, order:ORDER_DESC, requested_by_external_user:{id:'30594028',type:1},with_unread_count:true" |
2 https://github.com/fullstorydev/grpcurl
1 |
grpcurl -plaintext -emit-defaults -d '{"lozon_id": 15515160432000}' -H 'User-Name: grpcurl' localhost:7020 points/FindPointByLozonID |
How to analyze the performance of your go application in production
You should definitely use chi’s middleware for running pprof and stuff in your admin panel. That’s the repo — https://github.com/go-chi/chi That’s the profiler — https://github.com/go-chi/chi/blob/master/middleware/profiler.go CPU profiling After that you can run something like this in shell:
1 |
go tool pprof -png ~/Downloads/profile |
Or just open it in the browser:
1 |
go tool pprof -http=:1234 ~/Downloads/profile |
If it opens something different then your browser (sublime …
Using GOPROXY with go mod
1 |
GOPROXY=https://<some_url> go mod download |
PostgreSQL: TOP slow queries
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
SELECT rolname, calls, total_time, mean_time, max_time, stddev_time, rows, query, regexp_replace(query, '[ \t\n]+', ' ', 'g') AS query_oneline FROM pg_stat_statements JOIN pg_roles r ON r.oid = userid WHERE calls > 100 AND rolname NOT LIKE '%backup' ORDER BY mean_time DESC LIMIT 15; |
How to hide face with iMovie
If you want to edit a video on mac and want to hide some part of the scene, there’s one easy way I found to do it with iMovie. I didn’t find a way, I’ve found a video about that. https://www.youtube.com/watch?v=nSC_Rje68FI
Nice list of image resizer libs in go
With speedtests and other nice things. https://github.com/fawick/speedtest-resize I tried these two: https://github.com/disintegration/imaging https://github.com/bamiaux/rez They are quite the same talking about file sizes and imaging is muuch easier to use.