Skip to content

Instantly share code, notes, and snippets.

View thiagozs's full-sized avatar
:octocat:
Have a nice day

Thiago Zilli Sarmento thiagozs

:octocat:
Have a nice day
View GitHub Profile
@thiagozs
thiagozs / pforward.sh
Last active July 1, 2021 13:29
pforward.sh
#!/bin/sh
# sed for remove ANSI from terminal
# For Mac OSX or BSD use
# sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g'
# services-xxx
kubectl port-forward -n $1 $(kubectl get pods -n $1 | grep 'services-xxx' | awk '{print $1}' | head -n 1 | sed $'s,\x1b\\[[0-9;]*[a-zA-Z],,g') 5000:5000 &
process_id1=$!
# services-yyy
package main
import (
"errors"
"fmt"
"log"
"net/http"
"net/http/httputil"
"net/url"
)
@thiagozs
thiagozs / invisblechar.go
Created May 11, 2021 13:25
Invisible char check and validation
package main
import (
"fmt"
"regexp"
"strings"
"unicode"
validation "github.com/go-ozzo/ozzo-validation/v4"
)
@thiagozs
thiagozs / ginbind.go
Created April 29, 2021 14:32
Gin bind query form params e json data
package main
import "log"
import "github.com/gin-gonic/gin"
type Person struct {
Name string `form:"name" json:"name"`
Address string `form:"address" json:"address"`
}
@thiagozs
thiagozs / hmacgen.go
Created April 7, 2021 13:50
Generating a SHA256 HMAC Hash
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
)
func main() {
@thiagozs
thiagozs / unscapestr.go
Created March 18, 2021 12:52
Escape and UnScape string characters
package main
import (
"encoding/json"
"fmt"
"strings"
)
func dumpMap(space string, m map[string]interface{}) {
for k, v := range m {
@thiagozs
thiagozs / gorm_arrstr.go
Created March 4, 2021 17:31
Gorm with array string with mysql and sqlite
package main
import (
"database/sql/driver"
"errors"
"fmt"
"log"
"reflect"
"strings"
"time"
@thiagozs
thiagozs / truncate.go
Created November 25, 2020 15:05
Truncate high number float precision
package main
import (
"fmt"
"math"
)
func main() {
//f := float64(1 << 63) // 9223372036854775808.0
f := 9.81522728482908E7
@thiagozs
thiagozs / bq-utils.go
Created November 20, 2020 14:09
Civil date and convert float from bigquery
package main
import (
"cloud.google.com/go/civil"
"fmt"
"strconv"
"time"
)
func main() {
package main
import (
"database/sql"
"fmt"
"time"
_ "github.com/mattn/go-sqlite3"
)