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 / 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 / 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
@thiagozs
thiagozs / golang_template_tips.md
Created August 1, 2023 15:50
Golang template tips

How to use Go text templates

October 20, 2021 7 min read2011

Using Golang Templates

Templates are files that define a specific pattern and give room for automation, be it a simple text file or an HTML file for a webpage. If it provides space for customization, it is a template.

You can write programming logic to parse simple templates, but as the level of customization in your template increases, the programming logic you need to customize increases, making it less feasible to write template parsing logic.

@thiagozs
thiagozs / install_zsh.sh
Created June 27, 2023 21:25
Install zsh script
#!/bin/bash
# Update package lists
sudo apt-get update
# Check if Zsh is installed, and if not, install it
if ! command -v zsh &> /dev/null
then
echo "Zsh is not installed. Installing..."
sudo apt-get install -y zsh
<!-- Game canvas -->
<canvas id="c"></canvas>
<!-- Gameplay HUD -->
<div class="hud">
<div class="hud__score">
<div class="score-lbl"></div>
<div class="cube-count-lbl"></div>
</div>
<div class="pause-btn"><div></div></div>
@thiagozs
thiagozs / eventemitter.go
Created May 29, 2023 19:13
Test case eventemitter golang chalenge
package eventemitter
import (
"fmt"
)
type Data func(data interface{})
var (
datas = make(map[string][]Data)
@thiagozs
thiagozs / bluetooth-reconnect
Created April 24, 2023 14:11 — forked from AndBondStyle/bluetooth-reconnect
Simple linux service for brute-force bluetooth auto-connection
#!/bin/bash
# Miminum delay between iterations, in seconds
delay=10
# Pairs of [bluetooth MAC, test expression]
targets=(
"98:B6:E9:47:F0:4F" "test ! -e /dev/input/js0"
"98:B6:E9:72:6C:31" "test -z \"\$(bluetoothctl info 98:B6:E9:72:6C:31 | grep 'Connected: yes')\""
)
@thiagozs
thiagozs / cosmos.sh
Created April 17, 2023 17:22
=Cosmos scripts bootstrap
#!/bin/bash
rm -r ~/.simapp
cd ~/workspace/cosmos-sdk
./build/simd tendermint unsafe-reset-all
./build/simd init demo
./build/simd keys --keyring-backend test add b9lab
./build/simd add-genesis-account --keyring-backend test b9lab 100000000stake
./build/simd gentx --keyring-backend test b9lab 70000000stake --chain-id $(jq -r '.chain_id' ~/.simapp/config/genesis.json)
./build/simd collect-gentxs
@thiagozs
thiagozs / keybase.md
Created April 14, 2023 17:33
Keybase proof

Keybase proof

I hereby claim:

  • I am thiagozs on github.
  • I am thiagozs (https://keybase.io/thiagozs) on keybase.
  • I have a public key ASApUHr6Hze-uyJtilGgWwKkkyIF0FSP5vnkelRxx0q2zwo

To claim this, I am signing this object:

@thiagozs
thiagozs / aws-lambda-calculator.go
Created March 15, 2023 21:09
AWS lambda calculator
package main
import (
"flag"
"fmt"
)
type Pricing struct {
Region string
PerRequestPrice float64 // in USD per 1 million requests