Skip to content

Instantly share code, notes, and snippets.

View nicolasparada's full-sized avatar
👨‍💻

Nicolás Parada nicolasparada

👨‍💻
View GitHub Profile
@nicolasparada
nicolasparada / slug.go
Created September 14, 2024 20:06
Slugify
package slug
import (
"crypto/rand"
"fmt"
"math/big"
"regexp"
"strings"
"unicode"
"unicode/utf8"
@nicolasparada
nicolasparada / renderer.go
Last active February 11, 2024 05:17
renderer.go
package renderer
import (
"fmt"
"html/template"
"io"
"io/fs"
"path/filepath"
"sync"
)
@nicolasparada
nicolasparada / cursor.go
Last active May 17, 2024 13:00
Cursor Type for Pagination. Implements Text, JSON and GQL Marshalers.
package types
import (
"context"
"fmt"
"io"
"time"
"github.com/btcsuite/btcutil/base58"
"github.com/vmihailenco/msgpack/v5"
@nicolasparada
nicolasparada / tx.go
Last active November 4, 2022 03:58
Golang SQL transaction wrapper
package db
import (
"context"
"database/sql"
"github.com/cockroachdb/cockroach-go/v2/crdb"
)
var ctxKeyTx = struct{ name string }{"ctx-key-tx"}
@nicolasparada
nicolasparada / yaml_ordered_map.go
Last active October 26, 2022 17:10
YAML ordered / sortered map marshaller
package property
import (
"fmt"
"strings"
"gopkg.in/yaml.v3"
)
// Properties list.
@nicolasparada
nicolasparada / shared.go
Created June 22, 2022 23:18
generic shared data
package main
import (
"fmt"
"reflect"
)
func main() {
render(MyData{Foo: "bar"})
}
@nicolasparada
nicolasparada / go.json
Created June 22, 2022 21:35
VSCode Bubble Tea snippet
{
"New Bubble Tea Program": {
"prefix": "bubbletea",
"body": [
"package main",
"",
"import (",
"\t\"fmt\"",
"\t\"os\"",
"",
@nicolasparada
nicolasparada / main.go
Created February 3, 2022 17:20
Bubbletea many views
package main
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
package errs
const (
ErrUnauthenticated = UnauthenticatedError("unauthenticated")
ErrInvalidArgument = InvalidArgumentError("invalid argument")
ErrNotFound = NotFoundError("not found")
ErrConflict = ConflictError("conflict")
ErrPermissionDenied = PermissionDeniedError("permission denied")
ErrGone = GoneError("gone")
)
@nicolasparada
nicolasparada / counter.html.tmpl
Last active October 11, 2023 19:54
Golang partial rendering component
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Golang Counter Component</title>
<link rel="shortcut icon" href="data:,">
<style>
@media (prefers-color-scheme: dark) {
:root {