Enjoy these free Code Nuggets?

Your support helps us create more high-quality content and unlocks exclusive premium nuggets via a personal activation link.

Support Our Work & Get Exclusive Access
πŸ€– New β€” AI Training

Learn to code with AI, not just about it.

Beyond free snippets, we run hands-on training in AI-assisted coding β€” teaching developers, teams and beginners how to build real software faster using modern AI tools. You bring the ideas; we show you how to ship them with an AI pair-programmer at your side.

  • βœ” Prompting & pairing with AI coding assistants to write, debug and refactor real code
  • βœ” Turning plain-English ideas into working apps, scripts and automations
  • βœ” Reviewing AI output safely β€” spotting bugs, security gaps and hallucinations
  • βœ” Live cohorts, team workshops and 1-on-1 mentoring β€” remote or on-site in Kenya
ai-pair-session.md

# You describe it…

"Build me a booking form that emails the client."

# …the AI drafts it…

β–Έ generating form + mailer…

β–Έ 24 lines written, 0 errors

# …and we teach you to lead it.

✱ You stay the engineer. AI is the tool.

All Code Nuggets

41 nuggets found

AfyaCore HMIS: Master Patient Index & FEFO Pharmacy Inventory Engine (Premium)

High-volume hospital EMR architecture combining longitudinal patient record indexing, FEFO (First Expired First Out) stock batch control, and M-Pesa/insurance billing reconciliation.Requires Premium Membership (KES 500/month) to unlock full database schema,...

// AfyaCore HMIS FEFO Stock Allocation Engine
namespace App\Services;

class PharmacyBatchService {
    public function allocateFEFOStock(int $itemId, int $requestedQty): array {
        $batches = StoreBatch::where('item_id', $itemId)
            ->where('quantity_remaining', '>', 0)
            ->...

PlatePoa ALPR: OpenCV & PyTorch License Plate Extraction Pipeline (Premium)

Automated License Plate Recognition (ALPR) model running YOLOv8 detection, homography perspective deskewing, and EasyOCR character parsing optimized for East African registration plates.

# PlatePoa AI Vehicle Plate Extractor
import cv2
import torch
import numpy as np

def extract_plate_number(image_path, model, ocr_reader):
    img = cv2.imread(image_path)
    results = model(img)
    
    for r in results:
        boxes = r.boxes.xyxy.cpu().numpy()
        for box in boxes:...

Network SIEM: Wazuh Syslog Collector & Automated IP Containment (Premium)

Python python

Real-time threat monitoring pipeline ingesting Syslog streams, identifying SSH/Nginx brute-force attacks, and executing automated IPTables / UFW firewall IP drops.

# Network SIEM Automated Containment Handler
import sys
import json
import subprocess

def handle_wazuh_alert(alert_data):
    rule_id = alert_data.get("rule", {}).get("id")
    src_ip = alert_data.get("data", {}).get("srcip")
    
    # Rule 5712: SSH Brute force attack detected
    if rule_id in [...

TB Detection AI: DenseNet-121 Chest X-Ray Diagnostic Assistant (Premium)

Medical computer vision model predicting pulmonary Tuberculosis opacity from DICOM/PNG chest X-rays with Grad-CAM visual heatmaps for radiologist validation.

# TB Detection AI Model Inference
import torch
import torchvision.transforms as transforms
from PIL import Image

def predict_tb(image_path, model):
    transform = transforms.Compose([
        transforms.Resize((224, 224)),
        transforms.ToTensor(),
        transforms.Normalize(mean=[0.485, 0....

Dynamics 365 Business Central: AL Language M-Pesa Invoice Sync (Premium)

Business Central AL Extension connecting customer general ledger accounts with automated M-Pesa STK Push payment reconciliations and invoice posting.

// Business Central AL M-Pesa Invoice Reconciliation Codeunit
codeunit 50100 "MPesa Payment Handler"
{
    trigger OnRun()
    begin
    end;

    procedure ProcessMPesaCallback(DocNo: Code[20]; AmountPaid: Decimal; TransCode: Code[30])
    var
        CustLedgerEntry: Record "Cust. Ledger Entry";...

KenyaVerified Gateway: National ID & Business Registry Verification API (Premium)

PHP php

Unified identity verification & anti-fraud gateway for verifying Kenya National ID numbers, business registration status, and tax compliance via secure REST webhooks.

// KenyaVerified National Registry Verification API
namespace App\Services;

use Illuminate\Support\Facades\Http;

class KenyaVerifiedService {
    public static function verifyNationalId(string $idNumber, string $dob): array {
        $response = Http::withHeaders([
            'X-API-KEY' => confi...

Polling the Meta Graph API with Auto-Pagination in Python

Python python

The Meta Graph API returns results one page at a time. Every response that has more data includes a paging.next cursor URL. The pattern below wraps that into a single...

import requests
import time
from collections import Counter

BASE = "https://graph.facebook.com/v20.0"


# ── helpers ──────────────────────────────────────────────────────────────
def g(url: str, token: str, params: dict = None) -> dict:
    """GET a Graph API endpoint, automatically injecting the...

Generating Styled Excel & PowerPoint Reports Automatically with Python

Python python

After collecting data from APIs or scraping, the next step is usually turning it into a document a non-technical stakeholder can open and read. openpyxl writes styled Excel workbooks; python-pptx...

# pip install openpyxl python-pptx

import openpyxl
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
from openpyxl.utils import get_column_letter

from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor


# ── shared theme ────────────...

Automating FTP Deployments in Python with Smart Change Detection & Retry

Python python

Manually uploading files over FTP after every code change is error-prone and slow. A Python script using the built-in ftplib module can automate this completely β€” uploading only changed files,...

"""
ftp_deploy.py β€” upload only changed files, retry on drop, clear caches.

Usage:
    python ftp_deploy.py
"""
import ftplib
import io
import os
import socket
import time
import urllib.request
import urllib.error

# ── config ────────────────────────────────────────────────────────────────
FTP_HOS...