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
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 / 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 / gist:c432b3700dad76b2a2a32bac36540aab
Created June 13, 2022 18:50
Get Pod Capacity for Kubernetes Node
kubectl get nodes -o=custom-columns=NAME:.metadata.name,CAPACITY:.status.capacity.pods
@rnemeth90
rnemeth90 / gist:80044f79ef31afded5c45a49ef8258fb
Last active June 11, 2022 16:09
AKS Node Pool with Labels
resource "azurerm_kubernetes_cluster_node_pool" "np" {
name = var.node_pool_name
kubernetes_cluster_id = azurerm_kubernetes_cluster.k8s.id
vm_size = var.np_size
node_count = var.np_count
enable_auto_scaling = var.np-enable_auto_scaling
max_count = var.np-enable_auto_scaling_max_count
min_count = var.np-enable_auto_scaling_min_count
zones = (var.np-availability_zones == "") ? [] : split(",", var.np-availability_zones)
max_pods = var.np-max_pods
@rnemeth90
rnemeth90 / gist:bbb452aaa193c7d7d55bf37159ec3f06
Created May 27, 2022 13:36
Simple Examples of Invoking Rest Endpoints with Powershell
Simple GET example
$response = Invoke-RestMethod 'http://example.com/api/people'
# assuming the response was in this format { "items": [] }
# we can now extract the child people like this
$people = $response.items
GET with custom headers example
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("X-DATE", '9/29/2014')
$headers.Add("X-SIGNATURE", '234j123l4kl23j41l23k4j')
$headers.Add("X-API-KEY", 'testuser')
@rnemeth90
rnemeth90 / gist:12ba652e14f62f540bc30277e3e470f5
Created May 20, 2022 12:27
Live Packet Capture of a Pod in Kubernetes
Summary:
Run tcpdump on a pod and then see that information through Wireshark locally on my machine.
Topology
--------
[laptop with wireshark] ------> [AKS Node] ------> [POD (tcpdump is here)].
##1. Create the fifo on your local machine (where wireshark will run)
```
mkfifo /tmp/remote-capture.fifo
@rnemeth90
rnemeth90 / program.cs
Created April 28, 2022 17:25
Get HostName Extended File Attribute using C# and Powershell
using System.Diagnostics;
string path = @"C:\Path\to\your\file.txt";
ProcessStartInfo processInfo = new ProcessStartInfo();
processInfo.FileName = @"powershell.exe";
processInfo.Arguments = $@"-Command $ErrorActionPreference = 'Stop'; $VerbosePreference = 'Continue'; $ProgressPreference = 'SilentlyContinue';
$fi = Get-ItemProperty -Path '{path}';
$ShellApplication = New-Object -ComObject Shell.Application;
$ShellFolder = $ShellApplication.Namespace($fi.Directory.FullName);
@rnemeth90
rnemeth90 / gist:e83bb4c8808f0d28412cb40edb2487d3
Created April 6, 2022 19:43
Delete Terminating Kubernetes Namespaces with Bash
#!/bin/bash
namespaces=$(kubectl get ns --field-selector=status.phase==Terminating -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}')
if [ -z "$namespaces"]
then
echo "No namespaces to delete."
exit
else
for namespace in $namespaces
@rnemeth90
rnemeth90 / gist:19d7de622a5009c1cf908c5d4deb5358
Created April 6, 2022 19:41
Delete Terminating Kubernetes Namespaces with Powershell
$terminatingNamespaces = kubectl get ns --field-selector=status.phase==Terminating -o jsonpath="{range .items[*]}{.metadata.name}{'\n'}{end}"
foreach ($ns in $terminatingNamespaces) {
Write-Verbose '[FOUND]: Forcefully removing $ns'
$jsonObj = kubectl get namespace $ns -o json | ConvertFrom-Json | foreach-object { $_.spec.finalizers = @(); $_ } |
convertto-json | kubectl replace --raw /api/v1/namespaces/$namespace/finalize -f -
}
@rnemeth90
rnemeth90 / GoogleDorking.md
Created March 23, 2022 15:38 — forked from sundowndev/GoogleDorking.md
Google dork cheatsheet

Google dork cheatsheet

Search filters

Filter Description Example
allintext Searches for occurrences of all the keywords given. allintext:"keyword"
intext Searches for the occurrences of keywords all at once or one at a time. intext:"keyword"
inurl Searches for a URL matching one of the keywords. inurl:"keyword"
allinurl Searches for a URL matching all the keywords in the query. allinurl:"keyword"
intitle Searches for occurrences of keywords in title all or one. intitle:"keyword"