Skip to content

Instantly share code, notes, and snippets.

View aldric's full-sized avatar

Aldric Gaudinot aldric

View GitHub Profile
@aldric
aldric / Edge-AI-RAG-Blueprint.ts
Created January 6, 2026 20:14
Operational Efficiency via Cloudflare Workers AI & Vectorize
/**
* ARCHITECTURAL BLUEPRINT: Cloudflare-Native RAG System
* Use Case: Real-time compliance/manual lookup for 12k+ affiliate sites.
*/
import { Ai } from '@cloudflare/ai'
export interface Env {
AI: any;
VECTOR_INDEX: VectorizeIndex;
@aldric
aldric / ADR-000-Manifesto.md
Created January 6, 2026 20:06
Standardizing Governance for High-Scale Platforms (12k+ Sites / €300M Transactions)

ADR-000: Architectural Decision Record (ADR) Manifesto

Status: Permanent | Architect: Aldric Gaudinot

Context

In ecosystems managing 12,000+ web properties (Blue Window) and €300M+ in financial transactions, "tribal knowledge" is a systemic risk. To ensure platform resilience and PCI-DSS compliance, every critical architectural shift must be codified.

The Decision

We mandate the use of ADRs for all platform-level changes. An ADR is not just a document; it is a historical record of intent that prevents "architectural drift" and ensures long-term maintainability.

Implementation Standard

@aldric
aldric / cf_logpush_config.sh
Last active January 6, 2026 20:40
Cloudflare Native OTel Export
curl -X POST "https://api.cloudflare.com/client/v4/zones/{ZONE_ID}/logpush/jobs" \
-H "Authorization: Bearer {API_TOKEN}" \
-H "Content-Type: application/json" \
--data '{
"name": "cloudflare-to-elastic",
"destination_conf": "https://<ELASTIC_AGENT_HOST>:5044/cloudflare.logs?header=Authorization&value=Bearer%20{KEY}",
"dataset": "http_requests",
"logpull_options": "fields=ClientIP,ClientRequestHost,ClientRequestMethod,EdgeStartTimestamp,EdgeResponseStatus,WAFAction,BotScore",
"enabled": true
}'
@aldric
aldric / live_banner_resize.ts
Last active January 6, 2026 19:39
In iGaming affiliate marketing, speed is everything. A 100ms delay in loading a landing page or an affiliate asset can lead to a significant drop in conversion (Flicker effect). This setup focuses on Edge-native performance, R2 image delivery.
/*
The Vary: Accept Header: This is the secret sauce. It ensures that when a Chrome user (AVIF) and a legacy browser user (PNG) hit the same URL, Cloudflare's CDN caches and serves the correct version to each, without re-running the Worker.
Binding over Fetch: By using env.IMAGES_ENGINE instead of fetch('/cdn-cgi/image/...'), you avoid the "sub-request limit" and get significantly lower internal latency within the Cloudflare network.
Metadata Stripping: Affiliate banners often contain sensitive "Created By" or "GPS" metadata from design tools. metadata: 'none' automatically scrubs this while saving extra kilobytes.
*/
import { Hono } from 'hon o'
type Bindings = {
#!/usr/bin/env python
# ============================================================================
# Apache Beam - Batch Processing Pipeline
# Process files from Google Cloud Storage → Apache Beam → BigQuery
#
# Features:
# - Read Avro/JSON files from GCS
# - Data validation and transformation
# - Deduplication by event_id
# - Write to BigQuery with WRITE_APPEND mode
@aldric
aldric / cf-zt.tf
Last active January 6, 2026 19:06
Cloudflare Zero Trust – Complete Terraform Configuration
# ============================================================================
# CLOUDFLARE ZERO TRUST - PRODUCTION CONFIGURATION
# Complete setup: SAML + Device Posture + Malware Blocking + Audit Logging
# ============================================================================
terraform {
required_version = ">= 1.0"
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
const filteredEdges = edges.reduce((acc, current) => {
const x = acc.find(item => item.source === current.source && item.target === current.target);
if (!x) {
return acc.concat([current]);
} else {
return acc;
}
}, []);
@aldric
aldric / cron-logs.sh
Created October 11, 2019 06:53
Sample bash script to send any text file, filter the content and send it to a ftp server - useful for log analysis
#!/bin/bash
# Sample bash script to send any file (here server access logs), filter the content and send it to a ftp server
FTP_SERVER=''
FTP_USER=''
FTP_PASS=''
FTP_FOLDER=''
# Find the previous *complete* access file.
import * as firebase from 'firebase/app';
import campaigns from './reference-data/data.json';
public batchUpdateby500() {
const camps = campaigns
.sort((a, b) => a.id - b.id)
.map((c) => {
const channel = 'channels';
const brand = 'brands';
@aldric
aldric / firestore.ts
Created July 31, 2019 10:14
Firestore Batch update subcollection
import * as firebase from 'firebase/app';
public updateCountries() {
this.getCountries().subscribe((countries) => {
const batch = this.firestore.firestore.batch();
countries.forEach(element => {
const ref = this.firestore
.collection('at-settings')
.doc('countries')
.collection('values')