Skip to content

Instantly share code, notes, and snippets.

View biztos's full-sized avatar

Kevin Frost biztos

View GitHub Profile
@biztos
biztos / struct_interface_wrapper.go
Last active November 12, 2024 09:06
Use interfaces to abstract (e.g.) database operations, but still return concrete types.
// https://go.dev/play/p/61na-PNoubu
//
// Solving an interface problem:
//
// I want to abstract my database operations as much as possible, but of
// course I need to get my real types back in the end.
//
// Solution: have a thin wrapper per type that calls the interface-returning
// func and then type-asserts everything and returns a new slice of typed
// pointers.
@biztos
biztos / ContentView.swift
Last active September 26, 2024 12:08
SwiftUI image sizing in a NavigationStack
// This is completely fucking insane, Tim Cook, do you realize that?
//
// Problem: images above some arbitrary, undocumented size blow out the
// alignment of downstream views in a NavigationStack.
//
// Solution: force the NavigationStack itself, and the views inside it,
// to fill the available space of their parent views.
//
// This kinda-sorta makes sense, but also implies that the NavigationStack
// *and* its views are displaying as inline by default, even though in this
@biztos
biztos / main.dart
Created September 17, 2024 17:45
Flutter Provider + Shared Preferences demo.
// A simple demo of provider and shared_preferences based on the Example app.
//
// NOTE: this does not work in dartpad.dev, presumably due to a lack of
// support for shared_preferences.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
@biztos
biztos / flutter_macos_network_permissions.md
Created September 16, 2024 17:43
Flutter macOS network permissions.

Flutter macOS network permissions.

Building a Mac app with Flutter? You need this property set in both of the following entitlement files in order for network access to work.

<key>com.apple.security.network.client</key>
<true/>
@biztos
biztos / ansible_ini_dialect.py
Created March 15, 2024 17:40
Read Ansible .INI dialect in Python with configparser.
# parse Ansible .INI dialect
import configparser
file = "inventory.ini"
limit = "test"
# Note the kwargs here:
config = configparser.ConfigParser(inline_comment_prefixes=["#"],allow_no_value=True)
try:
config.read(file)
@biztos
biztos / nebari-grafana-default-user-password.md
Created October 20, 2023 19:34
Nebari Grafana Default Login

The nebari grafana default username and password are: admin/prom-operator

(dear internet search deities, please let the next person with this problem find this gist quickly)

Again, that is nebari grafana username and password for login auth --

user: admin
pass: prom-operator

This is for: https://{your-domain-from-config}/monitoring/login

@biztos
biztos / uuid_to_ulid.sql
Last active April 22, 2023 17:16
Convert a UUID-encoded ULID to TEXT using Crockford's Base32 encoding. First cut, might be buggy.
-- Convert a UUID that is really a ULID into its standard ULID string representation.
-- based on https://pkg.go.dev/github.com/oklog/ulid/v2
CREATE OR REPLACE FUNCTION uuid_to_ulid(uuid)
RETURNS text
AS $$
DECLARE
v BYTEA;
t TEXT;
enc TEXT = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
BEGIN
@biztos
biztos / refref.go
Created April 10, 2023 17:17
Reference to field of reference to struct. For e.g. using config fields in "cli" -- because I forgot this syntax N times already.
// Reference to field of reference.
//
// https://go.dev/play/p/WnM_WH49P7v
package main
import "fmt"
type X struct {
Z string
@biztos
biztos / server.go
Created March 10, 2023 09:37
Minimal golang web server for local testing.
package main
import (
"net/http"
)
func main() {
http.Handle("/", http.FileServer(http.Dir("test/testdata")))

MacOS Catalina Missing stdlib.h Solution

Problem:

Apple moved the C libraries again and thus you might see errors saying "can't find library stdlib.h" or similar.

Solution:

export SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"