Skip to content

Instantly share code, notes, and snippets.

package main
import (
"log"
"time"
"github.com/labstack/echo/v5"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/apis"
"github.com/pocketbase/pocketbase/core"
@kalafut
kalafut / go-snippets.md
Last active December 21, 2018 07:14
Go Snippets

Helpers that are meant to be copied, pasted and modified... not imported.

Cryptography

The secretbox library is intended to minimize the number of ways to screw things up, but using it still requires some setup.

func Seal(data, key []byte) []byte {
	if len(key) != 32 {
		panic("invalid key length")
	}

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@kalafut
kalafut / logical_system.go
Created March 30, 2018 04:53
Example that really slows vim-go's package comment folding
package vault
import (
"context"
"crypto/sha256"
"crypto/sha512"
"encoding/base64"
"encoding/hex"
"encoding/json"
"errors"
@kalafut
kalafut / django_init
Last active February 21, 2024 07:48
Simple creation of a single-app django project
#!/bin/bash
#
# Simple creation of a single-app django project, as described in: https://zindilis.com/posts/django-anatomy-for-single-app/
#
# ./django_init foo
#
# This will result is the following flat structure:
#
# .
# └── foo
@kalafut
kalafut / example.go
Created October 11, 2015 19:15
Sample file that will generate gorename errors
package main
// Running gorename -from example.go::Foo -to foo on this file will not work.
// There are multiple errors, but it appears that gorename stops after the first one.
//
// example.go:16:6: renaming this type "Foo" to "foo"
// example.go:21:6: conflicts with func in same block
//
// After commenting out or changing foo(), the errors moves down:
//
@kalafut
kalafut / pinextract.py
Created June 19, 2014 23:19
Retrieve bookmarks from Pindroid
import json
import sqlite3
output = []
conn = sqlite3.connect('PinboardBookmarks.db')
c = conn.cursor()
for row in c.execute("SELECT url, description, tags FROM bookmark"):
output.append({"href": row[0], "description": row[1], "tags": row[2]})