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.
Simple way to detect browser’s FPS via JS
It’s dumb and dead simple but works. You can even track browser’s metrics with that.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
(() => { const times = []; let fps; function refreshLoop() { window.requestAnimationFrame(() => { const now = performance.now(); while (times.length > 0 && times[0] <= now - 1000) { times.shift(); } times.push(now); fps = times.length; refreshLoop(); }); } refreshLoop(); // output to console once per second setInterval(() => {console.log(fps);}, 1000) })(); |
Mocking for testing go code
If you’re testing go code and have a huge API you have to mock, you have two options: make your dummy struct with embedded interface and implement only methods you need, or use your own interface that has only methods you need (and change your code to use that). For instance, I had amazon’s s3 …
BDD Framework For Golang
There is a good one: https://github.com/onsi/ginkgo It prefers to use http://onsi.github.io/gomega/ as a matcher.