Skip to content

Instantly share code, notes, and snippets.

View nicolasparada's full-sized avatar
👨‍💻

Nicolás Parada nicolasparada

👨‍💻
View GitHub Profile
@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 / 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 {
@nicolasparada
nicolasparada / client.js
Last active September 18, 2023 15:58
Newline Delimited JSON (NDJSON) Demo
const abortController = new AbortController()
fetch('/api/ndjson', {
headers: { accept: 'application/x-ndjson' },
signal: abortController.signal,
}).then(async res => {
const reader = res.body.getReader()
const textDecoder = new TextDecoder()
try {
@nicolasparada
nicolasparada / cursor.go
Created July 26, 2023 19:46
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 / 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() {
@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 / gestures.md
Last active October 16, 2022 15:40
Switch desktop in Windows 10 with three fingers gesture. Working on HP Spectre x360 with Synaptics.

Gestures

Virtual key codes:

  • 3 keys: 0x33
  • Ctrl key: 0x11
  • Windows key: 0x5B
  • Left arrow key: 0x25
  • Right arrow key: 0x27
@nicolasparada
nicolasparada / shared.go
Created June 22, 2022 23:18
generic shared data
package main
import (
"fmt"
"reflect"
)
func main() {
render(MyData{Foo: "bar"})
}