Skip to content

Instantly share code, notes, and snippets.

@rothgar
rothgar / talos-root.sh
Created April 10, 2024 23:57
Get a "host" shell on Talos Linux
#!/usr/bin/env bash
if ! command -v kubectl &>/dev/null; then
echo "kubectl not be found"
exit 1
fi
if ! command -v fzf &>/dev/null; then
echo "fzf not be found"
exit 1
fi
@alexedwards
alexedwards / Makefile
Last active March 17, 2026 18:09
Boilerplate Makefile for Go projects
# Change these variables as necessary.
main_package_path = ./cmd/example
binary_name = example
# ==================================================================================== #
# HELPERS
# ==================================================================================== #
## help: print this help message
.PHONY: help
import (
"fmt"
"strings"
"regexp"
)
func main() {
snakeCase := ConvertToSnakeCase("ILikeProgrammingINGo123")
fmt.Println("String in snake case : ", snakeCase)
import (
"fmt"
"strings"
"strconv"
)
func main() {
result := ConvertSliceToString([]int{10, 20, 30, 40})
fmt.Println("Slice converted string : ", result)
import "fmt"
func main() {
s := []int{10, 20, 30}
sum := sumSlice(s)
fmt.Println("Sum of slice elements : ", sum)
}
import "fmt"
func main() {
a := []int{1, 2, 3, 4, 5, 6} // input int array
reverseArray := ReverseSlice(a)
fmt.Println("Reverted array : ", reverseArray) // print output
}
func ReverseSlice(a []int) []int {
import "fmt"
func main() {
// shuffle array
array := []string{"India", "US", "Canada", "UK"}
Shuffle(array)
}
func Shuffle(array []string) {
// seed random for changing order of elements
import "fmt"
func main() {
// define array of strings
fruits := []string{"Mango", "Grapes", "Kiwi", "Apple", "Grapes"}
fmt.Println("Array before removing duplicates : ", fruits)
// Array after duplicates removal
dulicatesRemovedArray := RemoveDuplicatesFromSlice(fruits)
fmt.Println("Array after removing duplicates : ", dulicatesRemovedArray)
import "fmt"
func main() {
smallerNo := 5
largerNo := 25
result := float32(smallerNo) / float32(largerNo)
fmt.Println("result : ", result)
}
import (
"time"
"fmt"
)
func main() {
timeZone := "Asia/Kolkata" // timezone value
loc, _ := time.LoadLocation(timeZone)
currentTime = time.Now().In(loc)
fmt.Println("currentTime : ", currentTime)