Skip to content

Instantly share code, notes, and snippets.

View mikalv's full-sized avatar

Mikal mikalv

View GitHub Profile
@mikalv
mikalv / vim-cheats.md
Created January 28, 2025 10:39 — forked from Starefossen/vim-cheats.md
My vim cheat sheet for working with tabs and window splits.

Tabs

New Tab

  • :tabnew - new blank tab
  • :tabedit [file] - open file in tab

Cursor Movement

  • gt (:tabn) - next tab
@cbaatz
cbaatz / gen_prefixed_id.sql
Created March 17, 2024 20:48
PostgreSQL function to generate a random ID using [0-9A-Za-z] with a fixed prefix.
-- SELECT gen_prefixed_id('account_', 20);
-- account_9f2oOuK23Xpv3rdtHnQY
-- Example usage in a table column definition:
-- id text DEFAULT gen_prefixed_id('account_', 16) PRIMARY KEY
-- Load the built-in pgcrypto module if not loaded.
CREATE EXTENSION IF NOT EXISTS pgcrypto;
-- Create a function that takes a text prefix and the length of the
@onatcipli
onatcipli / go_router_example.dart
Last active August 25, 2025 07:37
go_router_example.dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
main() {
CustomNavigationHelper.instance;
runApp(const App());
}
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
@4np
4np / WireGuard iOS HOWTO.md
Last active September 18, 2025 19:32
Setting up WireGuard to secure iPhone traffic

WireGuard

How to set up WireGuard as an iOS VPN configuration in order to tunnel all traffic from an iOS or iPadOS device through a Linux server.

While there are many configurations possible, my intentation was to secure the traffic from my iOS device by routing it securely through a Linux server. As such, this HowTo will show you how to set-up an initial working configuration, which you can customize afterward.

Most likely things will be missing, such as how to configure the firewall or the init scripts on your Linux distribution. As it won't be possible to cover all Linux flavors this HowTo will attempt to give you a working WireGuard configuration, leaving it up to you to fill-in the blanks. Feel free to write a comment to touch upon your specific situation to help others that might stumble upon this HowTo :)

Note: In these configuration examples I use 10.8.0.1/24 and 10.8.0.2/24. However, as WireGuard IPs may not overlap your other network interfaces

@kconner
kconner / macOS Internals.md
Last active October 8, 2025 16:45
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@ttesmer
ttesmer / AD.hs
Last active October 29, 2024 15:35
Automatic Differentiation in 38 lines of Haskell using Operator Overloading and Dual Numbers. Inspired by conal.net/papers/beautiful-differentiation
{-# LANGUAGE TypeSynonymInstances #-}
data Dual d = D Float d deriving Show
type Float' = Float
diff :: (Dual Float' -> Dual Float') -> Float -> Float'
diff f x = y'
where D y y' = f (D x 1)
class VectorSpace v where
zero :: v

Poor Man's Global Traffic Manager

Sometimes we need to add redundancy to some service or server which happen to be a public-facing entry point of our infrastructure. For example, imagine we want to add a high availability pair for a load balancer which sits on the edge of network and forwards traffic to alive backend servers.

                                             ┌─────────────┐
                                             │             │
                                      ┌─────►│  Backend 1  │
                                      │      │             │
                                      │      └─────────────┘
@mateuszkwiatkowski
mateuszkwiatkowski / vscode-remote-ssh-freebsd.md
Last active October 8, 2025 19:18
Configure FreeBSD to work with VScode's remote ssh extension

This procedure was tested on FreeBSD-CURRENT build from d8819d88af52.

  1. Enable linuxulator and install linux userland:
    # sysrc linux_enable="YES"
    # service linux start
    # pkg install linux_base-c7
    
@AnomalRoil
AnomalRoil / go-switch-bash
Last active July 1, 2022 13:37
The `go switch` function allows you to easily switch you current Go version
# to add to your ~/.bashrc or your ~/.zshrc file. Usage: $ go switch 1.18.1
function go() {
case $* in
switch* )
shift 1
gobindir=$(go env GOBIN)
# adapt to a valid directory at the beginning of your $PATH if you're not on systemd
homebindir=$(systemd-path user-binaries)
go install golang.org/dl/go"$@"@latest
$gobindir/go"$@" download
@mdegat01
mdegat01 / update_notifications.yaml
Last active September 24, 2025 13:54
Update Notifications Automation Blueprint
blueprint:
name: Update notifications
description: Send notifications for new updates and install or skip on action
homeassistant:
min_version: '2022.4.0'
domain: automation
input:
update_entities:
name: Update entities
description: >-