Skip to content

Instantly share code, notes, and snippets.

View borud's full-sized avatar

Bjørn Borud borud

View GitHub Profile

Keybase proof

I hereby claim:

  • I am borud on github.
  • I am borud (https://keybase.io/borud) on keybase.
  • I have a public key ASCIDyn4US9NmGqSvSM_v0FIVc7PpwrrtcGnU8R4qiVF4wo

To claim this, I am signing this object:

@borud
borud / main.go
Created February 19, 2025 17:48
Read the PEM file containing an encrypted PKCS#8 key
package main
import (
"encoding/pem"
"fmt"
"log"
"os"
"github.com/youmark/pkcs8"
)
@borud
borud / broadcastable.go
Last active June 9, 2022 08:51
Sample of one to many channel broadcast using generics
package main
import (
"fmt"
"log"
"time"
)
type broadcastable interface{}
@borud
borud / base36.go
Last active March 26, 2022 22:38
convert uint64 to base36
package main
import (
"fmt"
"math/big"
"os"
"strconv"
)
func main() {
@borud
borud / formwrapper.go
Last active September 10, 2021 11:00
Allow urlencoded forms to be handled in grpc-gateway
// formWrapper converts a POST'ed form to the JSON object we want. grpc-gateway doesn't
// normally accept anything other than application/json, so we intercept anything that
// has Content-Type equal to "application/x-www-form-urlencoded".
func formWrapper(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// If we can't get the media type this request we just pass it on
mediaType, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
if err != nil {
h.ServeHTTP(w, r)
return
@borud
borud / static-binary-with-sqlite.txt
Created August 25, 2021 10:35
How to build static binary with SQLite
go build -o mybinary -tags osusergo,netgo,sqlite_omit_load_extension -ldflags="-linkmode external -extldflags=-static"
@borud
borud / note.txt
Last active July 25, 2016 10:26
Raspberry Pi Locale
# Fix locale problems on Raspberry Pi
This supposedly fixes locale issues on Raspberry Pi. Be aware that
this is slow as fuck.
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales