Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am wingedpig on github.
  • I am wingedpig (https://keybase.io/wingedpig) on keybase.
  • I have a public key whose fingerprint is 9CA1 E916 3F41 58EA 2E82 ACDA 5991 7671 8F41 E07C

To claim this, I am signing this object:

@wingedpig
wingedpig / testproducer.go
Last active October 5, 2017 16:46
Test Kafka producer
package main
import (
"fmt"
"log"
"os"
"strings"
"sync"
"github.com/Shopify/sarama"
@wingedpig
wingedpig / testconsumer.go
Created October 5, 2017 16:47
Test Kafka Consumer
package main
import (
"log"
"os"
"os/signal"
"github.com/Shopify/sarama"
)
@wingedpig
wingedpig / testpage.go
Created October 14, 2020 20:47
A thought experiment about a new Go-based UI framework.
package testpage
/*
This is a thought experiment about a new Go-based UI framework. A project to accomplish the same thing as React or Vue.js.
I strongly dislike Javascript and all the existing reactive UI frameworks. For whatever reason, and try as I might, I cannot get my head around
them. Hence this thought experiment about what kind of UI framework I would like to use.
== Goals ==
- I want to be able to build a responsive website easily.
// ReadConfig reads in a JSON-formatted configuration file, looking for any
// include directives, and recursively reading those files as well. Include directives
// are specified as a list keyed on the "Includes" key.
func ReadConfig(filename string, configuration interface{}) error {
// grab any path to the config file to add to the include names
var prefix string
slashindex := strings.LastIndex(filename, "/")
if slashindex != -1 {
prefix = filename[:slashindex+1]
{
"UserDbConfig": {
"URL": "user=groupsio password=dev host=127.0.0.1 dbname=userdb",
"MaxIdleConnections": 1,
"MaxOpenConnections": 10,
"ConnMaxLifetime": 0,
"Replica": false
}
}
{
"Includes": [
"userdb_conf.json"
],
"Port": 3000
}
package userdb
type Config struct {
URL string
MaxIdleConnections int
MaxOpenConnections int
ConnMaxLifetime int
Replica bool
}
package main
type Config struct {
Includes []string
UserDbConfig userdb.Config
Port int
}
@wingedpig
wingedpig / chatgptparseexport.go
Created April 23, 2023 15:30
A Go program to parse ChatGPT export files
package main
import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"sort"