Skip to content

Instantly share code, notes, and snippets.

View xavier268's full-sized avatar

xavier268 xavier268

View GitHub Profile
@xavier268
xavier268 / gist:d85fbafbf1c9381f7a6734c25b99d58f
Created October 27, 2025 09:53
wait until user type enter or time out exceeded
func waitForAction(d time.Duration) {
input := make(chan bool, 1)
// Start a goroutine to wait for user input
go func() {
fmt.Printf("\nPress Enter to exit immediately, or wait %v...\n", d)
fmt.Scanln() // Wait for user to press Enter
input <- true
}()
@xavier268
xavier268 / gist:1016ad0d3d154b600bc196a26af349b1
Created December 31, 2024 11:42
Symetric (distance),square, dynamically extended matrix implementation
package distance
import (
"fmt"
"strings"
)
// A distance matrix
// Optimised for storage efficiency.
// Zero value can be used immediately.