Skip to content

Instantly share code, notes, and snippets.

talabat
- aws:284691955762:eu-central-1:hardy-albacore
- aws:284691955762:eu-central-1:tidy-hornet
- aws:284691955762:eu-central-1:sharing-raccoon
- aws:284691955762:eu-central-1:probable-muskrat
- aws:284691955762:eu-central-1:cuddly-koi
- aws:284691955762:eu-central-1:sterling-snail
efood
package main
import (
"context"
"crypto/x509"
"encoding/pem"
"fmt"
"os"
"github.com/deliveryhero/pd-sts-go-sdk/introspect"
@Julian-Chu
Julian-Chu / postgres_array.go
Created October 30, 2020 09:02 — forked from adharris/postgres_array.go
PostgreSQL demo of Array types using Golang
package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/bmizerany/pq"
"os"
"regexp"
"strings"
@Julian-Chu
Julian-Chu / join_test.go
Created April 7, 2020 09:41 — forked from dtjm/join_test.go
strings.Join vs fmt.Sprintf vs string concat (+)
package join
import (
"fmt"
"strings"
"testing"
)
var (
testData = []string{"a", "b", "c", "d", "e"}
@Julian-Chu
Julian-Chu / how-to-copy-aws-rds-to-local.md
Created September 29, 2019 10:00 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
var dataLarge []byte
const size = 64 * 1024 //65536
func Benchmark_LargeSize_Heap(b *testing.B) {
for i := 0; i < b.N; i++ {
dataLarge = make([]byte, size)
}
}
func Benchmark_LargeSize_Pool_ReturnNonpointer(b *testing.B) {
var bytePool = sync.Pool{
package structescape
import "testing"
type DataContainer struct {
a []byte
}
var d *DataContainer
package stacksizetest
import (
"testing"
)
const size = 64 * 1024 //65536
func Benchmark_LargeSize_Stack_EqualOrLess65535(b *testing.B) {
for i := 0; i < b.N; i++ {
func main() {
ok, msg := Validate(2, GreaterThan10, GreaterThanZero, LessThan100)
fmt.Println(ok, ":", msg)
}
func Validate(val int, fs ...func(int) (bool, string)) (bool, string) {
for _, f := range fs {
ok, msg := f(val)
if !ok {
return ok, msg
func Test_Something(t *testing.T){
teardown, err := setup(t)
defer teardown()
// run tests
}