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 / gomock.md
Last active April 19, 2024 03:45
Tutorial gomock

08/16/17 by  Sergey Grebenshchikov

No Comments

This is a quick tutorial on how to test code using the GoMock mocking library and the standard library testing package testing.

GoMock is a mock framework for Go. It enjoys a somewhat official status as part of the github.com/golang organization, integrates well with the built-in testing package, and provides a flexible expectation API.

@thiagozs
thiagozs / hamburger.html
Last active March 8, 2024 20:59
HTML hamburger menu tailwindcss javascript
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<!-- FONTS -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
@thiagozs
thiagozs / duration_totext.go
Last active December 19, 2023 17:23
BairesDev Transform duration to Text
package main
import "fmt"
func solution (seconds int) string {
if seconds == 0 {
return "now"
}
@thiagozs
thiagozs / food_ratings.go
Created December 19, 2023 14:28
BaieresDev golang challenge
package main
import "fmt"
func solution (n int, ratings [][]int) int {
dishRatings := make(map[int][2]int)
for i := 0; i < n; i++ {
dishID, rating := ratings[i][0], ratings[i][1]
@thiagozs
thiagozs / echo-ratelimit.go
Created November 28, 2023 15:12
Poc Redis Rate Limit middleware
package main
import (
"context"
"fmt"
"net/http"
"time"
"github.com/go-redis/redis/v8"
"github.com/labstack/echo/v4"
@thiagozs
thiagozs / kubernetes.md
Created September 30, 2021 13:17
sheet codes development day

Kubectl Kubernetes Free CheatSheet

1.1 Common Commands

Run curl test temporarily

kubectl run --generator=run-pod/v1 --rm mytest --image=yauritux/busybox-curl -it

Run wget test temporarily

@thiagozs
thiagozs / paseto_exthex.go
Created September 21, 2023 20:44
Paseto secret external Hex
package main
import (
"fmt"
"aidanwoods.dev/go-paseto"
)
func main() {
@thiagozs
thiagozs / show_create_table.sql
Last active September 18, 2023 12:52
Postgres show create table script
CREATE OR REPLACE FUNCTION public.show_create_table(
in_schema_name varchar,
in_table_name varchar
)
RETURNS text
LANGUAGE plpgsql VOLATILE
AS
$$
DECLARE
-- the ddl we're building
@thiagozs
thiagozs / file-opening-flags-go.md
Created September 18, 2023 12:26
File-opening flags in Go

File-opening flags in Go (By Adebayo Adams)

Go provides file-opening flags represented by constants defined in the os package. These flags determine the behavior of file operations, such as opening, creating, and truncating files. The following is a list of the flags and what they do.

  1. os.O_RDONLY: Opens the file as read-only. The file must exist.

  2. os.O_WRONLY: Opens the file as write-only. If the file exists, its contents are truncated. If it doesn't exist, a new file is created.

  3. os.O_RDWR: Opens the file for reading and writing. If the file exists, its contents are truncated. If it doesn't exist, a new file is created.

@thiagozs
thiagozs / Makefile
Created August 23, 2023 17:23
Makefile with golang-migrate
BINARY_NAMES="golang-migrate|migrate"
DATABASE="mysql://root:password@tcp(localhost:3306)/test"
.PHONY: checkdeps help
help: ## Displays the help for each command.
@grep -E '^[a-zA-Z_-]+:.*## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
dbu: ## Migrates the database to the latest version.
migrate -database="$(DATABASE)" -path=migrations -lock-timeout=20 -verbose up