Skip to content

Instantly share code, notes, and snippets.

@mohashari
mohashari / snippet-1.txt
Created July 11, 2026 01:03
Building a Custom Triton Inference Server C++ Backend for Sequence-to-Sequence Models — code snippets
// triton_seq2seq_backend.h
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <cuda_runtime.h>
#include "triton/backend/backend_common.h"
#include "triton/backend/backend_model.h"
#include "triton/backend/backend_model_instance.h"
@mohashari
mohashari / snippet-1.hcl
Created July 11, 2026 01:02
Hardening CI/CD Pipelines: Ephemeral Self-Hosted Runner Orchestration on AWS EC2 with GitHub Actions OIDC and HashiCorp Vault — code snippets
# Configure the OIDC/JWT Auth Backend for GitHub Actions in HashiCorp Vault
resource "vault_jwt_auth_backend" "github" {
description = "JWT Auth backend for GitHub Actions OIDC tokens"
path = "github-actions"
oidc_discovery_url = "https://token.actions.githubusercontent.com"
bound_issuer = "https://token.actions.githubusercontent.com"
}
# Define a policy that allows reading dynamic database credentials
resource "vault_policy" "production_db_read" {
@mohashari
mohashari / snippet-1.txt
Created July 11, 2026 01:02
Implementing a Zero-Copy LSM-Tree Storage Engine with io_uring in Rust — code snippets
use io_uring::{opcode, squeue, types, IoUring};
use std::fs::File;
use std::os::unix::io::AsRawFd;
use std::alloc::{alloc, dealloc, Layout};
pub struct StorageRing {
ring: IoUring,
registered_buffers: Vec<*mut u8>,
buffer_layout: Layout,
}
@mohashari
mohashari / snippet-1.go
Created July 11, 2026 01:01
Optimizing TCP Connection Pool Exhaustion Debugging with eBPF and bpftrace — code snippets
package main
import (
"context"
"io"
"log"
"net/http"
"time"
)
@mohashari
mohashari / snippet-1.go
Created July 11, 2026 00:43
Building a Zero-Allocation Garbage-Collector-Aware Skip List in Go for High-Throughput In-Memory Indexes — code snippets
package main
import (
"bytes"
"errors"
"math/rand"
"sync"
"sync/atomic"
)
@mohashari
mohashari / snippet-1.yaml
Created July 11, 2026 00:42
Designing an Automated Secret Zero Bootstrapping Pipeline in Kubernetes using TPM 2.0 and SPIFFE/SPIRE — code snippets
# SPIRE Server configuration snippet for TPM 2.0 node attestation
server {
bind_address = "0.0.0.0"
bind_port = "8081"
trust_domain = "prod.muklis.internal"
data_dir = "/run/spire/data"
log_level = "INFO"
ca_key_type = "rsa-2048"
ca_ttl = "24h"
@mohashari
mohashari / snippet-1.py
Created July 11, 2026 00:41
Implementing Semantic Cache Coherency in Multi-Node LLM Deployments using Redis Raft — code snippets
import numpy as np
from qdrant_client import QdrantClient
from qdrant_client.http import models
class SemanticVectorResolver:
def __init__(self, host: str, port: int, collection_name: str, threshold: float = 0.88):
self.client = QdrantClient(host=host, port=port)
self.collection_name = collection_name
self.threshold = threshold
@mohashari
mohashari / snippet-1.txt
Created July 11, 2026 00:41
Correlating eBPF Socket Event Tracing with OpenTelemetry Context in Distributed Environments — code snippets
#include <uapi/linux/bpf.h>
#include <linux/sched.h>
#include <net/sock.h>
#include <net/inet_connection_sock.h>
#include <bcc/proto.h>
#define MAX_PAYLOAD_READ 256
#define TRACEPARENT_LEN 55
struct conn_info_t {
@mohashari
mohashari / snippet-1.txt
Created July 10, 2026 15:46
Profiling Heap Allocations in Production Rust Services with Jemalloc and Grafana Pyroscope — code snippets
// Cargo.toml configuration:
// [dependencies]
// tikv-jemallocator = { version = "0.6", features = ["profiling", "unprefixed_malloc_on_supported_platforms"] }
// tikv-jemalloc-ctl = "0.6"
// tokio = { version = "1.0", features = ["full"] }
use std::alloc::System;
#[global_allocator]
static GLOBAL: tikv-jemallocator::Jemalloc = tikv-jemallocator::Jemalloc;
@mohashari
mohashari / snippet-1.txt
Created July 10, 2026 15:44
Designing a Custom Write-Ahead Log (WAL) with Zero-Copy Direct I/O in Rust — code snippets
use std::alloc::{alloc, dealloc, Layout};
use std::ptr::NonNull;
pub struct AlignedBuffer {
ptr: NonNull<u8>,
layout: Layout,
capacity: usize,
}
impl AlignedBuffer {