Skip to content

Instantly share code, notes, and snippets.

@gchait
gchait / steam_inventory.py
Created December 13, 2025 11:54
Fetch a Steam inventory as JSON
#!/usr/bin/env python3
"""
Steam inventory dumper with JSON output.
Output formats:
- Default: Pretty-printed JSON with nested structure
- --flat: JSONL (one item per line) for streaming/grep
Examples:
./steam_inventory.py <steamid64>
@gchait
gchait / jenkins_lambda.py
Created December 13, 2025 12:05
Trigger a Jenkins job from an AWS Lambda
"""
This simply functions as a reverse-proxy to a Jenkins job.
It allows granting the source access only to this specific action,
instead of requiring direct network access to the Jenkins server.
"""
from os import getenv
from urllib.parse import quote
from urllib.request import Request, urlopen
@gchait
gchait / log-date-fmt.sh
Created December 13, 2025 12:10
Align date and time while streaming logs
# shellcheck disable=SC2154
"${tail_command[@]}" | while read -r datetime rest; do
new_datetime=$("${DATEUTIL}" -d "${datetime} UTC" +"%d/%m/%y %H:%M:%S")
echo "${new_datetime} ${rest}"
done
@gchait
gchait / run-ecs-task.sh
Created December 13, 2025 12:14
Treat an ECS task as a job
# shellcheck disable=SC2086
set -o allexport
source .env
set +o allexport
cluster_args="--cluster ${ECS_CLUSTER} --region ${REGION}"
net_config="{\"awsvpcConfiguration\":{\"assignPublicIp\":\"XXX\",\"subnets\":[\"${SUBNET_ID}\"]}}"
task_arn=$(aws ecs run-task ${cluster_args} \
--task-definition "${ECS_TASK_DEF_ARN}" --launch-type FARGATE \
@gchait
gchait / Dockerfile
Created December 13, 2025 12:19
Extend Flink Operator with plugins
FROM ghcr.io/apache/flink-kubernetes-operator:xxxxx
ARG PLUGINS="flink-s3-fs-hadoop flink-s3-fs-presto"
ENV FLINK_PLUGINS_DIR=/opt/flink/plugins
ENV BASE_PLUGIN_JARS_URL=https://repo1.maven.org/maven2/org/apache/flink
RUN cd ${FLINK_PLUGINS_DIR} \
&& flink_version=$(ls ./flink-metrics-prometheus | cut -d"-" -f4 | sed "s/.jar//") \
&& for plugin in ${PLUGINS}; \
@gchait
gchait / clean-previous-images.sh
Created December 13, 2025 12:22
Keep only a specific tag from a Docker repository
# shellcheck disable=SC2086
docker images -q "${DOCKER_REPO_FULL}" | \
grep -v "$(docker images -q ${DOCKER_IMAGE})" | \
xargs --no-run-if-empty docker rmi -f
@gchait
gchait / grype_exporter.py
Created December 13, 2025 12:28
Expose Grype-found vulnerabilities to Prometheus
from itertools import islice
from subprocess import run
from tempfile import NamedTemporaryFile
from time import sleep
from typing import NamedTuple
import kubernetes.client
import kubernetes.config
import prometheus_client
@gchait
gchait / uvicorn_filter.py
Created December 13, 2025 12:40
Hide an endpoint from Uvicorn access logs
class EndpointFilter(Filter):
"""A generic way to filter out web endpoints from the logs."""
# pylint: disable=too-few-public-methods
def __init__(
self,
path: str,
*args,
**kwargs,
@gchait
gchait / msk-privatelink.tf
Created December 13, 2025 12:46
An old and involved way to PrivateLink MSK brokers
@gchait
gchait / provision-with-sudo.sh
Created December 13, 2025 12:50
Run many functions as root with injected environment variables
provision() {
xx() {
:
}
yy() {
:
}
zz() {