Skip to content

Instantly share code, notes, and snippets.

@DoumanAsh
DoumanAsh / eks-swap-fix.yaml
Last active August 20, 2026 09:06
Daemon set to fix bad default setting for SWAP. This will reduce chances of Swap memory being used, while not disabling it completely. You want it when your nodes have sufficiently memory hungry workloads which will lead to Linux allocate more Swap than necessary, causing kswapd0 to be busy and eating your CPU, starving the node
apiVersion: v1
kind: ServiceAccount
metadata:
name: eks-swap-fixer-oneshot
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: eks-swap-fixer-oneshot
@DoumanAsh
DoumanAsh / ingress-so.yaml
Created March 27, 2026 11:51
KEDA concurrent request scaling object. AWS doesn't seem to have concurrent request count per individual request so we can only simulate it
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: alb-littles-law-per-second-scaledobject
namespace: default
spec:
scaleTargetRef:
name: my-app-deployment
minReplicaCount: 2
@DoumanAsh
DoumanAsh / create_temp_user.sql
Created July 18, 2025 06:15
Create read only user once PostgresSQL procedure
CREATE OR REPLACE PROCEDURE create_temp_user(user_id VARCHAR)
LANGUAGE plpgsql
AS $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_user WHERE usename = user_id) THEN
EXECUTE 'CREATE USER ' || user_id || ' WITH PASSWORD DISABLE';
EXECUTE 'GRANT SELECT ON ALL TABLES IN SCHEMA public TO ' || user_id;
EXECUTE 'GRANT USAGE ON SCHEMA public TO ' || user_id;
EXECUTE 'ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO ' || user_id;
END IF;
@DoumanAsh
DoumanAsh / main.ts
Last active April 22, 2025 05:13
AWS IoT Core Provisioning script
import { mqtt5, iot, iotidentity } from 'aws-iot-device-sdk-v2';
///Ensure at least once delivery should be enough most of the time
const QOS = mqtt5.QoS.AtLeastOnce;
///Environment config
const CONFIG = {
endpoint: process.env.IOT_CORE_ENDPOINT!,
cert: process.env.IOT_CORE_CERTIFICATE!,
priv_key: process.env.IOT_CORE_PKEY!,
@DoumanAsh
DoumanAsh / ls-errors.json
Last active March 1, 2024 08:32
nushell ls bug
[
{
"type": "error",
"code": "unknown",
"details": "Error extracting glob pattern"
},
{
"type": "file",
"size": 1501,
"modified": "2023-08-16 10:35:36.158743465 +09:00"
@DoumanAsh
DoumanAsh / alacritty.toml
Created February 21, 2024 07:14
Alacritty workaround for tmux tabs
# Mac OS settings with tmux
[shell]
program = "/opt/homebrew/bin/tmux"
args = [
"new-session",
"-A",
"-D",
"-s",
"main"
@DoumanAsh
DoumanAsh / termination.rs
Created February 14, 2024 10:58
tokio's signal handler to await termination
use core::future::Future;
use core::pin::Pin;
use core::task;
use std::io;
///Future that resolves when program is requested to terminate
#[must_use = "Future does nothing without polling"]
pub struct Termination {
#[cfg(unix)]
term: tokio::signal::unix::Signal,
@DoumanAsh
DoumanAsh / acme.sh
Last active October 29, 2024 15:27
Simple nginx config to hide redis behind TLS proxy (includes minimal configuration to run acme.sh)
# Make sure to create folder /www and grant write access to nginx and yourself
$DOMAIN="your domain"
# Create file structure to serve static file with challenge
sudo mkdir /www
sudo mkdir /www/.well-known/
sudo mkdir /www/.well-known/acme-challenge
sudo chown nginx /www/.well-known/acme-challenge
#As example grant group write permission (e.g. you want www to belong to nginx user and anyone in nginx group) do:
@DoumanAsh
DoumanAsh / waker.rs
Created February 10, 2024 02:59
AtomicWaker
use core::{ptr, task, hint, mem};
use core::cell::UnsafeCell;
use core::sync::atomic::{AtomicBool, AtomicU8, Ordering};
mod noop {
use core::{ptr, task};
const VTABLE: task::RawWakerVTable = task::RawWakerVTable::new(clone, action, action, action);
const WAKER: task::RawWaker = task::RawWaker::new(ptr::null(), &VTABLE);
@DoumanAsh
DoumanAsh / sample.log
Created February 6, 2024 06:33
kube-state-metrics with filter --resources=pods,cronjobs,jobs
# HELP kube_cronjob_annotations Kubernetes annotations converted to Prometheus labels.
# TYPE kube_cronjob_annotations gauge
# HELP kube_cronjob_labels [STABLE] Kubernetes labels converted to Prometheus labels.
# TYPE kube_cronjob_labels gauge
# HELP kube_cronjob_info [STABLE] Info about cronjob.
# TYPE kube_cronjob_info gauge
kube_cronjob_info{namespace="default",cronjob="demo",schedule="* * * * *",concurrency_policy="Forbid"} 1
# HELP kube_cronjob_created [STABLE] Unix creation timestamp
# TYPE kube_cronjob_created gauge
kube_cronjob_created{namespace="default",cronjob="demo"} 1.707200821e+09