Skip to content

Instantly share code, notes, and snippets.

View rafiramadhana's full-sized avatar

Rafi Ramadhana rafiramadhana

View GitHub Profile
@rafiramadhana
rafiramadhana / go.mod
Last active April 10, 2023 17:10
Find a number sequence inside an array of numbers
module zicarecoding
go 1.18
@rafiramadhana
rafiramadhana / not-rungkat.sh
Created March 12, 2023 03:46
Wait until MySQL not rungkat
#!/bin/sh
# Docker-compose check if mysql connection is ready
# https://stackoverflow.com/a/51641089
maxcounter=30
counter=1
while ! mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -h"0.0.0.0" -P"3306" -e "SHOW DATABASES;" > /dev/null 2>&1; do
sleep 1
counter=`expr $counter + 1`
if [ $counter -gt $maxcounter ]; then
@rafiramadhana
rafiramadhana / README.md
Last active November 28, 2022 12:55
go-switch

go-switch

Switching between Go version with ease

➜  ~ go-switch list
go1.13.15
go1.15
go1.16
go1.16.13
@rafiramadhana
rafiramadhana / proxy.txt
Last active April 11, 2021 16:16
to_proxy_or_not_to_proxy
Proxy servers are not the holy grail of internet surfing, that this video makes them out to be. There are drawbacks, too.
1) Proxy servers will speed up the retrieval of requests that you make -- but only if those requests were already made, and are in the proxy's cache. Otherwise, your request will be slower (even if you do not notice), because you are involving yet another computer to be a middle-man for a request that could be done directly, without the proxy.
Also know that your own computer has cache, that does the same thing. The advantage of using a proxy, is that if anyone else (that also uses the same proxy) has visited a site, and you visit the same site, then you will reap the benefit of using the proxy's cache for a faster response. But to be clear... if you both visit amazon, and you shop for different things, the cache will not help (only slight help, for data in common, like amazon specific logos, etc).
2) Your IP address is hidden, and it is not hidden. It depends on how much you trust
@rafiramadhana
rafiramadhana / simplewp.go
Created January 16, 2021 13:45
Simple Go Worker Pool
package main
import (
"log"
"time"
)
const (
NUMBER_OF_JOBS = 25
NUMBER_OF_WORKERS = 2
@rafiramadhana
rafiramadhana / ucov
Last active February 16, 2021 16:18
Unit test coverage check in Go
LOAD_TEST_ENV=env $$(cat .env.testing | xargs)
GOTEST=go test
GOTEST_PATH=./internal/usecase/...
GOCOVER=go tool cover
coverage:
$(LOAD_TEST_ENV) \
$(GOTEST) -tags=unit -coverprofile=cover.out $(GOTEST_PATH)
$(GOCOVER) -html=cover.out && unlink cover.out