Skip to content

Instantly share code, notes, and snippets.

View rnemeth90's full-sized avatar

Ryan Nemeth rnemeth90

View GitHub Profile
@rnemeth90
rnemeth90 / go-stdlib-interface-selected.md
Created December 19, 2023 13:24 — forked from asukakenji/go-stdlib-interface-selected.md
Go (Golang) Standard Library Interfaces (Selected)

Go (Golang) Standard Library Interfaces (Selected)

This is not an exhaustive list of all interfaces in Go's standard library. I only list those I think are important. Interfaces defined in frequently used packages (like io, fmt) are included. Interfaces that have significant importance are also included.

All of the following information is based on go version go1.8.3 darwin/amd64.

@rnemeth90
rnemeth90 / filewalk.go
Created June 24, 2023 09:57
Go filepath.walk example
package main
import (
"fmt"
"os"
"path"
"path/filepath"
)
func main() {
@rnemeth90
rnemeth90 / timeDiff.py
Created May 25, 2023 18:13
Calculate Diff of Two Time Strings in Python
from datetime import datetime
start_time = "10:44:09.339931"
end_time = "10:44:09.376233"
t1 = datetime.strptime(start_time, "%H:%M:%S.%f")
print('Start time:', t1.time())
t2 = datetime.strptime(end_time, "%H:%M:%S.%f")
print('End time:', t2.time())
@rnemeth90
rnemeth90 / binarySearch.go
Last active May 13, 2023 13:25
Go Binary Search
package main
import (
"fmt"
"math"
)
func main() {
fmt.Println("index", binarySearch([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 8))
}
@rnemeth90
rnemeth90 / linearSearch.go
Created May 13, 2023 10:12
Go Linear Search
package main
import (
"fmt"
)
func main() {
fmt.Println("index:", linearSearch([]int{2, 10, 40, 30, 21, 41, 56}, 10))
}
@rnemeth90
rnemeth90 / binaryTree.go
Created March 25, 2023 10:18
Golang: Equivalent Binary Trees
package main
import (
"fmt"
"golang.org/x/tour/tree"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
@rnemeth90
rnemeth90 / wordFrequency.go
Last active February 26, 2023 18:22
Golang: Count of Repeating Words in String
package main
import (
"fmt"
"strings"
)
func wordFrequency(text string) map[string]int {
input := strings.Fields(text)
wc := make(map[string]int)
@rnemeth90
rnemeth90 / privileged-deployment.yaml
Last active February 1, 2023 16:51
Privileged Pod Template
apiVersion: v1
kind: Pod
metadata:
name: security-context-demo
spec:
containers:
- name: sec-ctx-demo
image: busybox:1.28
command: [ "sh", "-c", "sleep 1h" ]
securityContext:
│ Error: Unsupported attribute
│ on main.tf line 96, in resource "azurerm_route_table" "route_tables":
│ 96: address_prefix = each.value.address_prefix
│ ├────────────────
│ │ each.value is object with 2 attributes
│ This object does not have an attribute named "address_prefix".
@rnemeth90
rnemeth90 / getPodCountPerNode.sh
Created October 7, 2022 19:17
Kubernetes: Get Count of Pods per Node
nodes=$(kubectl get nodes --no-headers | awk '{print $1}')
for n in ${nodes[@]}; do
pods=$(kubectl get pod -A --field-selector spec.nodeName=$n --no-headers | awk '{print $2}')
echo $n = $(echo $pods | wc -w)
done