Skip to content

Instantly share code, notes, and snippets.

View rnemeth90's full-sized avatar

Ryan Nemeth rnemeth90

View GitHub Profile
@rnemeth90
rnemeth90 / main.go
Last active July 18, 2022 14:38
Go FizzBuzz
package main
import (
"fmt"
"strconv"
)
func fizzbuzz(num int) string {
switch {
case num%15 == 0:
@rnemeth90
rnemeth90 / main.go
Created July 24, 2022 10:00
Go Concurrent Fibonacci Calculator
package main
import (
"fmt"
"math/rand"
"time"
)
func fib(ch chan string, number float64) {
x, y := 1.0, 1.0
@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
│ 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 / 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:
@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 / 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 / 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 / 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 / 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())