Skip to content

Instantly share code, notes, and snippets.

View maxsei's full-sized avatar

Maximillian Schulte maxsei

View GitHub Profile
@maxsei
maxsei / configuration.md
Last active June 13, 2024 03:30
configuration for sqlc issue: Support multiple conflict targets in upsert statements for SQLite parser

output

$ sqlc verify
line 5:0 extraneous input 'ON' expecting {<EOF>, ';', ALTER_, ANALYZE_, ATTACH_, BEGIN_, COMMIT_, CREATE_, DEFAULT_, DELETE_, DETACH_, DROP_, END_, EXPLAIN_, INSERT_, PRAGMA_, REINDEX_, RELEASE_, REPLACE_, ROLLBACK_, SAVEPOINT_, SELECT_, UPDATE_, VACUUM_, VALUES_, WITH_}
line 7:0 extraneous input '<EOF>' expecting {';', ALTER_, ANALYZE_, ATTACH_, BEGIN_, COMMIT_, CREATE_, DEFAULT_, DELETE_, DETACH_, DROP_, END_, EXPLAIN_, INSERT_, PRAGMA_, REINDEX_, RELEASE_, REPLACE_, ROLLBACK_, SAVEPOINT_, SELECT_, UPDATE_, VACUUM_, VALUES_, WITH_}
# package
query.sql:1:1: extraneous input '<EOF>' expecting {';', ALTER_, ANALYZE_, ATTACH_, BEGIN_, COMMIT_, CREATE_, DEFAULT_, DELETE_, DETACH_, DROP_, END_, EXPLAIN_, INSERT_, PRAGMA_, REINDEX_, RELEASE_, REPLACE_, ROLLBACK_, SAVEPOINT_, SELECT_, UPDATE_, VACUUM_, VALUES_, WITH_}
error verifying: errored
@maxsei
maxsei / main.go
Created June 7, 2024 19:14
uuid encoding sqlite
package main
import (
"database/sql"
"log"
"github.com/google/uuid"
_ "github.com/mattn/go-sqlite3"
)
@maxsei
maxsei / bench_test.go
Created June 7, 2024 18:44
Benchmarkign sqlite with uuid storage shcmes
package main
import (
"database/sql"
"encoding/binary"
"fmt"
"sort"
"strings"
"testing"
@maxsei
maxsei / random_string.go
Created June 6, 2024 21:48
random string generator golang
pacakge main
import (
"math/rand"
"unicode"
)
func randomString(n int) string {
res := make([]rune, n)
@maxsei
maxsei / index.html
Created June 3, 2024 16:25
Remove arrows from number inputs
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<style type="text/css" media="screen">
input.noarrows::-webkit-outer-spin-button,
input.noarrows::-webkit-inner-spin-button {
@maxsei
maxsei / types.go
Created May 22, 2024 19:31
service types
package main
import (
"time"
"github.com/google/uuid"
)
type (
SystemDeviceInfo struct {
package main
import "log"
type CounterMessage int
func main() {
var a1 *Actor
var a2 *Actor
@maxsei
maxsei / stream.go
Last active May 23, 2024 22:36
streaming for EnTeRpRiSe
package stream
import (
"context"
"errors"
"sync"
)
type CancelableMessage[T any] struct {
ctx context.Context
// go version go1.20.7 linux/amd64
package main
import (
"context"
"database/sql"
"errors"
"log"
"sync"
"time"
@maxsei
maxsei / materialized_view.go
Created April 26, 2024 22:45
crappy generic event sourcing with materialized views in go
package matview
// I have a go data structure that stores a buffer of events. The events are
// tuples of (K, V, OP) where K is a unique identifier for the event, V is other
// data associated with the event, and OP is an operation that is either PUT or
// DEL. For an event with a "PUT" OP, the event will be appended to the buffer
// of events, if the event's K exists then the value will be overwritten. For an
// event with a "DEL" OP, the event found and removed from the buffer. Consumers
// of this data structure subscribe and get the full state of the events stored
// and all subsequent events.