Skip to content

Instantly share code, notes, and snippets.

@freshteapot
freshteapot / 1-notes.md
Last active March 20, 2024 06:22
Adding new words to learn in Norwegian via photos from instagram on a mac

Adding new words to learn in Norwegian via photos from instagram on a mac

Save

Use Preview to copy the text out of the image

const a = `A sette
To put
A skrelle
To peel
A steke
@freshteapot
freshteapot / settings.md
Last active February 20, 2024 07:25
Using ginkgo / gomega, different ways to test what was passed to an interface

VScode / Vscodium options to make go look pretty when testing packages

{
    "go.coverageDecorator": {
        "type": "highlight",
        "coveredBorderColor": "rgba(64,128,128,0.8)",
        "coveredHighlightColor": "rgba(64,128,128,0.8)",
        "uncoveredHighlightColor": "rgba(128,64,64,0.5)",
 "uncoveredGutterStyle": "verticalred"
@freshteapot
freshteapot / note.md
Created January 14, 2024 09:32
= and LIKE do not use the same index

Today I learnt that using equals = does not use the same index as LIKE in sqlite

LIKE and = do not use the same indexes

Indexes

First one via ".expert in sqlite3 cli" <3

CREATE INDEX acl_simple_idx_0a4b252f ON acl_simple(access COLLATE NOCASE);

How to make vscode and ginkgo play nice on focused tests

"go.testEnvVars": {
        "GINKGO_EDITOR_INTEGRATION": true,
    },

Reference

@freshteapot
freshteapot / data.md
Last active December 1, 2023 11:33
Extract challenge data out from sql
WITH _base(uuid,user_uuid,kind,records,state) AS (
    SELECT uuid,user_uuid,kind,records,state FROM stats
),

_challenge_plank_per_user(uuid, user_uuid, total) AS (
    SELECT uuid, json_extract(value,'$.user_uuid'), SUM(json_extract(value,'$.timerNow')) FROM _base, json_each(records) WHERE kind='challenge.plank' GROUP BY uuid, json_extract(value,'$.user_uuid')
),

_challenge_plank_per_user_sum(uuid, total) AS (
@freshteapot
freshteapot / code.md
Last active December 1, 2023 10:01
Example ways of handling tier lockdown to encourage upgrades

Example of access to slideshow

func HasAccessBasedOnTierLimitsOnCreate(tier string, userInfo user.UserPreference, kind string) bool {
	if tier != "free" {
		return true
	}

	records := userInfo.Usage.Stats
	// assume keys exist?
	if _, ok := records[stats.SystemMissingKey]; ok {
@freshteapot
freshteapot / resize.sh
Created November 1, 2023 13:28
Resize from 6.5 to 5.5
#!/bin/bash
# Resize from 6.5 to 5.5
# Adapted from https://gist.github.com/fhasni/f741333d1437b1033652d30cc3e7543d
VERSION="1.0.3"
OUTPUT_DIR="output/scaled"
for filename in ./${VERSION}/*; do
w=$(printf "%.2f" $(echo '(1242/1284)*100' | bc -l))
h=$(printf "%.2f" $(echo '(2208/2778)*100' | bc -l))
mkdir -p $OUTPUT_DIR
@freshteapot
freshteapot / howto.md
Created October 21, 2023 11:42
Create a learning video with learnalist, upload to youtube and share the list data with youtube.

Make videos for youtube and share the data via learnalist

Steps

  • Create list
  • Include the verb
  • Set slideshow
  • Make video
  • Download video
  • Vist the main list
@freshteapot
freshteapot / openapi.md
Last active October 9, 2023 10:21
Build one large openapi document from subsets, ie different api endpoints or domain logic.
generate-openapi-one:
	rm -rf /tmp/openapi/one && \
	mkdir -p /tmp/openapi/one && \
	cp ./openapi/learnalist.yaml /tmp/openapi/one/ && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.version.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.asset.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.plank.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.user.yaml && \
	yq m -i /tmp/openapi/one/learnalist.yaml ./openapi/api.alist.yaml && \
@freshteapot
freshteapot / a.go
Created September 24, 2023 17:51
More exploring gojq + sqlite + event
package main
import (
"bufio"
"context"
"database/sql"
"encoding/json"
"fmt"
"log"
"os"