Skip to content

Instantly share code, notes, and snippets.

View arxdsilva's full-sized avatar
:octocat:
Working from home

Arthur Silva arxdsilva

:octocat:
Working from home
View GitHub Profile
package main
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"log"
"os"
"path"
@arxdsilva
arxdsilva / not_uuid.pgsql
Last active February 18, 2022 11:18
return text if not uuid
CREATE OR REPLACE FUNCTION public.null_or_not_uuid(str text)
RETURNS text
LANGUAGE plpgsql
AS $function$
declare
struuid uuid;
begin
struuid = str::uuid;
RETURN null;
EXCEPTION WHEN invalid_text_representation THEN

Keybase proof

I hereby claim:

  • I am arxdsilva on github.
  • I am arxdsilva (https://keybase.io/arxdsilva) on keybase.
  • I have a public key ASCzXbVUKxXNY62FR-O9gUY7YH4LxVEkHEU5VHtZ1pGnTAo

To claim this, I am signing this object:

package main
import (
"context"
"database/sql"
"encoding/json"
"github.com/heroiclabs/nakama-common/runtime"
)
// InitModule registers the RPC function into the game server
@arxdsilva
arxdsilva / main.go
Last active March 20, 2021 19:11
golang struct composition
package main
import (
"fmt"
)
type A struct {
Name string
Age string
}
@arxdsilva
arxdsilva / unmarshal_unknown_data.go
Created October 1, 2019 19:45
unmarshal unknown data
package main
// playground
// https://play.golang.org/p/dPmHZkw2QwB
import (
"fmt"
"encoding/json"
)
@arxdsilva
arxdsilva / replace.go
Last active July 29, 2019 17:58
string replacing in golang
package main
// info https://play.golang.org/p/uAWpm-rUc-1
import (
"fmt"
"strings"
)
func main() {
s := strings.Replace("nextpdf5,00reais_1564141286.pdf", ",", "", -1)
fmt.Println(s)
@arxdsilva
arxdsilva / decodeBase64.go
Last active June 5, 2019 17:45
decode a base 64 string in go
package main
// https://play.golang.org/p/utIG70ublyv
import (
b64 "encoding/base64"
"fmt"
)
func main() {
@arxdsilva
arxdsilva / timeout.go
Last active May 6, 2020 14:03
request timeout in golang
package main
import (
"fmt"
"io/ioutil"
"net/http"
"time"
)
func main() {
@arxdsilva
arxdsilva / fakeserver.go
Created June 5, 2019 17:39
fake server golang
package main
import (
"fmt"
"net/http"
"time"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {