Skip to content

Instantly share code, notes, and snippets.

View ftamhar's full-sized avatar
🏠
Working from home

Rahmat Fathoni ftamhar

🏠
Working from home
  • Indonesia
View GitHub Profile
@ftamhar
ftamhar / HaversinFormula.go
Created January 24, 2022 08:21 — forked from cdipaolo/HaversinFormula.go
Golang functions to calculate the distance in meters between long,lat points on Earth.
// haversin(θ) function
func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
// Distance function returns the distance (in meters) between two points of
// a given longitude and latitude relatively accurately (using a spherical
// approximation of the Earth) through the Haversin Distance Formula for
// great arc distance on a sphere with accuracy for small distances
//
@ftamhar
ftamhar / go_cpu_memory_profiling_benchmarks.sh
Created December 30, 2021 23:10 — forked from arsham/go_cpu_memory_profiling_benchmarks.sh
Go cpu and memory profiling benchmarks. #golang #benchmark
go test -run=. -bench=. -benchtime=5s -count 5 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./package | tee bench.txt
go tool pprof -http :8080 cpu.out
go tool pprof -http :8081 mem.out
go tool trace trace.out
go tool pprof $FILENAME.test cpu.out
# (pprof) list <func name>
# go get -u golang.org/x/perf/cmd/benchstat
benchstat bench.txt
@ftamhar
ftamhar / http2_apache2_ubuntu18.04.md
Created October 18, 2021 14:59 — forked from GAS85/http2_apache2_ubuntu18.04.md
How to Enable HTTP/2 in Apache 2.4 on Ubuntu 18.04

Requirements

  • A self-managed VPS or dedicated server with Ubuntu 18.04 running Apache 2.4.xx.
  • A registered domain name with working HTTPS (TLS/SSL). HTTP/2 only works alongside HTTPS because most browsers, including Firefox and Chrome, don’t support HTTP/2 in cleartext (non-TLS) mode.

Step 1: Install Apache2

@ftamhar
ftamhar / gist:13943ac082627d6ed45b1e9a378ca895
Created May 8, 2020 00:23 — forked from peymano/gist:2047968
Restore from a binary Postgres dump file
pg_restore --clean --no-acl --no-owner -d <database> -U <user> <filename.dump>