Skip to content

Instantly share code, notes, and snippets.

// longestCommonPrefix returns the string in compares that has the longest common prefix with s
func longestCommonPrefix(s string, compares ...string) string {
var longestMatched int
var longestCmp string
maxLength := len(s)
for _, c := range compares {
cmpLen := len(c)
if cmpLen > maxLength {
cmpLen = maxLength
}
function ask_yes_no() {
local prompt="$1"
while true; do
read -p "$prompt [y/n]?" yn
case "$yn" in
[Yy]* ) return 0;;
[Nn]* ) return 1;;
* ) echo "Please answer y or n";;
esac
done
package main
import (
"path"
"syscall"
)
// isMountPoint returns true if the given directory is a mountpoint
func isMountPoint(fileName string) (bool, error) {
dir := path.Clean(fileName)
@gammazero
gammazero / wp_track_jobs.go
Last active October 29, 2020 21:11
Track workerpool job completion
package main
import (
"context"
"errors"
"fmt"
"time"
"github.com/gammazero/workerpool"
)