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 / Makefile
Last active October 31, 2024 19:52
Makefile semver
.PHONY: help
## ENVIRONMENT VARIABLES
VERSION_FILE = release-candidate.txt
SEMVER ?= 0.1.0
CURRENT_VERSION := $(shell [ -f $(VERSION_FILE) ] && cat $(VERSION_FILE) || echo $(SEMVER))
# Self-Documented Makefile
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@thiagozs
thiagozs / dynscan.go
Created July 12, 2024 12:57
Dynamic scan you query DB to struct golang
package dynscan
import (
"database/sql"
"fmt"
"reflect"
"strings"
"time"
"github.com/google/uuid"
@thiagozs
thiagozs / ubuntu-usb-disable-usb-autosuspend.md
Created July 10, 2024 13:42
Ubuntu disable USB autosuspend

Disabling USB Auto-Suspend on Ubuntu

These days Linux supports a lot of devices. However, occasionally you will find a device that works but only for a while, requiring a reboot to work again. This is often due to the device itself not behaving according to the USB standard, and that's more often than not caused by misbehaving USB suspend.

The proper way of fixing this would be either a workaround in the driver or, God forbid, a fix in the device's firmware. But quite often nobody does anything, so what's left is to do the improper. And the easiest improper fix is to disable USB autosuspend.

For the command line, just add usbcore.autosuspend=-1 to GRUB_CMDLINE_LINUX_DEFAULT:

sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[a-z ]*/& usbcore.autosuspend=-1/' /etc/default/grub
@thiagozs
thiagozs / awsvpnclient-ubuntu-24.04.md
Created June 19, 2024 18:55
AWSVPNClient Fixes on ubuntu 24.04

Steps

Download

wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb

sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2.13_amd64.deb
@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 / 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 / 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.