Skip to content

Instantly share code, notes, and snippets.

@toddlers
toddlers / apigateway-invoke.py
Created September 3, 2021 09:37 — forked from Riebart/apigateway-invoke.py
Python script to invoke an AWS API Gateway endpoint that requires IAM authentication. Uses boto for signing the request, and requests for issuing it.
#!/usr/bin/env python3
"""
Provides a simple Python wrapper for invoking an API Gateway endpoint using IAM signed requests.
Example:
python3 apigateway-invoke.py GET \
https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/default/MethodName | jq .
"""
try:
@toddlers
toddlers / fileinfo.go
Created January 25, 2017 13:08
getting fileinfo in go
package main
import (
"fmt"
"os"
)
func main() {
// can handle symbolic link, but will no follow the link
@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'

AWS Cloudformation ApiGateway vs ApiGatewayV2 with Lambda

This shows how to convert a basic REST ApiGateway template to its equivalent HTTP ApiGatewayV2.

The original code before refactoring to ApiGatewayV2 comes from this article

Deployment

Replace MY_PROFILE, MY_REGION and MY_STACK_NAME

@toddlers
toddlers / dockerhubk8s.md
Last active July 28, 2024 20:30
docker hub with kubernetes in GKE
  • Step by step how to pull a private DockerHub hosted image in a Kubernetes YML.
export DOCKER_REGISTRY_SERVER=https://index.docker.io/v1/
export DOCKER_USER=Type your dockerhub username, same as when you `docker login`
export DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
export DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`
export SECRETNAME=acmeorg
@toddlers
toddlers / Dockerfile
Created July 27, 2016 11:24
using envsubst in Dockerfile
FROM ubuntu:trusty
RUN \
apt-get update \
&& apt-get -y install gettext-base \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV VALUE=foo
ENV VALUE1=boo
COPY config.txt source_config.txt
@toddlers
toddlers / jenkins_backup.sh
Created January 14, 2015 07:38
Jenkins_Bacup via jenkins
# Delete all files in the workspace
rm -rf *
# Create a directory for the job definitions
mkdir -p $BUILD_ID/jobs
# Copy global configuration files into the workspace
cp $JENKINS_HOME/*.xml $BUILD_ID/
# Copy keys and secrets into the workspace
cp $JENKINS_HOME/identity.key.enc $BUILD_ID/