Skip to content

Instantly share code, notes, and snippets.

@IamNator
IamNator / main.go
Created June 14, 2024 06:42
Clean Database Transactions in Go with GORM
package main
import (
"context"
"fmt"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
// Entity represents a database entity
@IamNator
IamNator / FbKeyMgmt.go
Last active January 18, 2024 16:45
fireblock-auth
package sdk
import (
"bytes"
crand "crypto/rand"
"crypto/rsa"
"crypto/sha256"
"crypto/tls"
"encoding/binary"
"encoding/hex"
var ErrorCodes = map[string]string{
"200": "successful",
"400": "Bad Request data",
"503": "Failed Transaction from the service provider",
"500": "Failed Transaction from the service provider",
"404": "Transaction / Resource not found",
"BX0001": "Connection Timeout: Retried 3 times and no response from the service provider",
"BX0002": "Transaction does not exist",
"BX0003": "Invalid request parameters data",
@IamNator
IamNator / check_env.sh
Created September 1, 2023 07:02
Check ALL ENV in a golang program
#!/bin/bash
# Replace 'application' with the actual path to your Go project directory
PROJECT_DIR="application"
OUTPUT_FILE="env_variables.yaml"
ENV_FILE="$1" # Specify the correct path to your optional environment file
# if $1 is help or -h, print help
@IamNator
IamNator / gist:53c8dd8bf9518f2963129d1798f06c08
Created August 23, 2023 05:49
golang file/folder structure
project_root
└───cmd
│ │ main.go
└───internal
│ │
│ └───models
│ │ │ card.go
│ │ │ wallet.go
@IamNator
IamNator / Makefile
Created April 6, 2023 16:53
Python code to generate infrastructure diagram
set:
export COMPANY_NAME="some_company"
run: diagram.py
python diagram.py
setup:
pip install diagrams
sudo apt update
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type checkContacts struct {
package oauth2
import (
"context"
"encoding/json"
"errors"
"fmt"
"inawo-services-api/pkg/env"
"os"
"time"

A simple Docker and Docker Compose install script for Ubuntu

Usage

  1. sh install-docker.sh
  2. log out
  3. log back in

Links

@IamNator
IamNator / main.go
Created July 3, 2021 06:14 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"