Skip to content

Instantly share code, notes, and snippets.

View manzanit0's full-sized avatar

Javier García manzanit0

View GitHub Profile
@manzanit0
manzanit0 / init.lua
Created April 1, 2025 08:38
Neovim config
---@diagnostic disable: undefined-global
if vim.g.vscode then
return
end
-- encoding
vim.o.encoding = "utf-8"
vim.o.fileencoding = "utf-8"
@manzanit0
manzanit0 / main.go
Created November 6, 2024 15:11
Managing NATS streams
const (
streamName = "my-stream"
consumerName = "my-consumer"
)
var subjects = []string{
"subject.foo",
"subject.bar",
}
@manzanit0
manzanit0 / parse_receipt.py
Created June 26, 2024 14:03
Python script to parse receipts with Chat GPT
#!/usr/bin/python3
import base64
import requests
# OpenAI API Key
api_key = "<INSERT KEY HERE>"
# Function to encode the image
def encode_image(image_path):
@manzanit0
manzanit0 / main.go
Created May 6, 2024 16:10
Using secrets manager
package main
import (
"context"
"log"
"strings"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
@manzanit0
manzanit0 / how-to.md
Last active February 27, 2024 20:46
Using container-structure-test to check if image runs as root
@manzanit0
manzanit0 / main.go
Created February 27, 2023 09:25
Go: Wrap HTTP mux
package main
import (
"fmt"
"log"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
)
@manzanit0
manzanit0 / gingko_subtests_test.go
Created February 22, 2023 09:23
Transcription of Ginkgo example with subtests
package gingko_subtests_test
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCheckingBooksOutOfLibrary(t *testing.T) {
t.Run("when the library has the book in question", func(t *t.Testing) {
t.Run("if the book is available, it lends it to the reader", func(t *t.Testing) {
@manzanit0
manzanit0 / main.go
Created October 4, 2022 08:07
Go naive worker pool toy
package main
import (
"fmt"
"log"
"sync"
)
type Input struct {
Id string
@manzanit0
manzanit0 / cancel.go
Last active September 29, 2022 20:40
Understanding how cancellation works
package main
import (
"context"
"fmt"
"sync"
"time"
)
// simply runs a program to showcase how to properly leverage
@manzanit0
manzanit0 / main.go
Last active July 12, 2022 21:26
Go: Running a request through an SSH tunnel
package main
import (
"io"
"io/ioutil"
"log"
"net"
"net/http"
"golang.org/x/crypto/ssh"