Skip to content

Instantly share code, notes, and snippets.

@toddlers
toddlers / commands.md
Created September 18, 2026 12:22
k8s_helpful

Quick and dirty query to find recent events indicating an unhealthy cluster (good one to run after maintenance):

kubectl get events -A --sort-by=.lastTimestamp | grep -iE 'preempt|evict|kill|fail|unhealthy|backoff'

And here's a kind of elaborate one to get actual CPU/memory usage vs requests/limits for right-sizing:

@toddlers
toddlers / go_mux_test_post.go
Created September 15, 2026 08:34
go_mux_test_post
// https://xeiaso.net/blog/go-servemux-slash-2021-11-04/
package main
import (
"fmt"
"io"
"net/http"
"net/http/httptest"
"strings"
@toddlers
toddlers / CKA exam cheat sheet
Created July 1, 2025 16:11 — forked from Nurlan199206/CKA exam cheat sheet
CKA exam cheat sheet
#================================================CKA EXAM CHEATSHEET KUBECTL==============================================#
commands for manage cluster, troubleshooting, debug etc...
#=========================================================================================================================#
useful resources: https://github.com/ascode-com/wiki/tree/main/certified-kubernetes-administrator
alias ll='ls -l'
alias kcr='kubectl create'
@toddlers
toddlers / func_pipe.rs
Created March 26, 2025 14:29
call pipe on any type, pass a closure and process
use std::fmt::Display;
trait Pipe:Sized {
fn pipe<F,R>(self, f:F) -> R
where
F: FnOnce(Self) -> R;
fn pipe_ref<F,R>(&self, f:F) -> R
where
F: FnOnce(&Self) -> R;
fn pipe_mut<'a, F,R>(&'a mut self, f:F) -> R
@toddlers
toddlers / micro_events.py
Created February 28, 2025 10:29 — forked from tarruda/micro_events.py
Micro event loop library to teach the basic concepts of python coroutines and how event loop libraries might be implemented
"""
A micro event loop library implementation from scratch.
This library provides a minimal but feature-complete asynchronous event loop
implementation for educational purposes. It demonstrates the core concepts of
asynchronous programming including:
- Task scheduling and management
- I/O multiplexing with non-blocking sockets
- Timeouts and sleep functionality
@toddlers
toddlers / aws-services.py
Created January 28, 2025 15:18 — forked from tdmalone/aws-services.py
Using an undocumented (and thus subject-to-change) API, provides a list of all AWS services colourised as to whether or not they're available in the given region. Alternatively, given two regions, colourised based on whether services are available in one region, both regions, or neither of them.
#!/usr/bin/env python
import json, sys
from urllib.request import urlopen
def green(str): return f'\033[92m{str}\033[0m'
def orange(str): return f'\033[38;5;214m{str}\033[0m'
def red(str): return f'\033[91m{str}\033[0m'
def yellow(str): return f'\033[93m{str}\033[0m'
@toddlers
toddlers / cargo.toml
Last active February 15, 2024 17:44
s3 presigned urls
[package]
name = "s3_presign"
version = "0.1.0"
edition = "2021"
# Starting in Rust 1.62 you can use `cargo add` to add dependencies
# to your project.
#
# If you're using an older Rust version,
# download cargo-edit(https://github.com/killercup/cargo-edit#installation)
@toddlers
toddlers / .gitignore
Created January 2, 2024 17:20 — forked from nicosingh/.gitignore
ECS using Terraform sample
*.tfbackup
.terraform/
*.tfstate
.terraform.tfstate.lock.info
@toddlers
toddlers / dexec.sh
Created June 27, 2023 17:03 — forked from papes1ns/dexec.sh
dexec.sh
#!/usr/bin/env bash
set -eu # do not proceed on error
if [ $# -lt 1 ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
cat <<EOF
Quick command to get a shell inside a running docker container.
Usage: dexec [container_name] [command]
@toddlers
toddlers / clock_gettime.c
Created October 11, 2022 17:16 — forked from pfigue/clock_gettime.c
Example of using libC clock_gettime() and clock_getres() functions.
#include <stdio.h>
#include <time.h>
int main(int argc, char **argv)
{
int result;
struct timespec tp;
clockid_t clk_id;