Skip to content

Instantly share code, notes, and snippets.

View tenox7's full-sized avatar

Antoni Sawicki tenox7

View GitHub Profile
@tenox7
tenox7 / funcname.go
Created June 7, 2023 11:18
returns caller name
func funcName() string {
pc, _, _, _ := runtime.Caller(1)
nm := runtime.FuncForPC(pc).Name()
dt := strings.Split(nm, ".")
return dt[len(dt)-1]
}
@tenox7
tenox7 / bleve_txt.go
Created May 15, 2024 06:15
example of how to index and search a directory of text files using bleve
package main
import (
"fmt"
"log"
"os"
"path"
"github.com/blevesearch/bleve/v2"
)
@tenox7
tenox7 / replace.go
Created January 11, 2025 21:52
Replace all characters with something
func replaceChars(str, repl, with string) string {
var oldnew []string
for _, char := range repl {
oldnew = append(oldnew, string(char), with)
}
return strings.NewReplacer(oldnew...).Replace(str)
}
@tenox7
tenox7 / disvc.sh
Last active January 13, 2025 04:55
Disable SysV Service
ds() { n=$(echo $1 | sed -e 's/^S/s/'); mv $1 $n; }