ruby
class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception

  before_action :authenticate_user!
end

CSRF protection for Rails and JSON APIs

csrf rails api
by Kai Nakamura 2 tabs
erb
<h1><%= @post.title %></h1>
<p><%= @post.author_name %></p>

<%# Only sanitized rich text should be rendered as HTML %>
<div class="prose"><%= sanitize(@post.body_html, tags: %w[p a ul ol li strong em code], attributes: %w[href]) %></div>

Cross site scripting defense with output encoding and CSP

xss content-security-policy owasp
by Kai Nakamura 3 tabs
ruby
# Vulnerable: user input is concatenated directly into SQL.
email = params[:email]
password = params[:password]

sql = "SELECT * FROM users WHERE email = '#{email}' AND password_hash = '#{password}'"
user = ActiveRecord::Base.connection.execute(sql).first

SQL injection prevention with unsafe and safe query patterns

sql-injection owasp database
by Kai Nakamura 3 tabs
python
import cv2

image = cv2.imread('receipt.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
thresholded = cv2.adaptiveThreshold(

OpenCV image preprocessing for OCR and vision pipelines

opencv image-processing computer-vision
by Dr. Elena Vasquez 1 tab
python
import geopandas as gpd
from shapely.geometry import Point

stores = gpd.read_file('stores.geojson').to_crs(epsg=3857)
customers = gpd.GeoDataFrame(
    customer_df,

Geospatial analysis with GeoPandas for location intelligence

geopandas geospatial analytics
by Dr. Elena Vasquez 1 tab
python
import re

text = 'INC-102301 resolved on 2026-04-06 after payment failure for order ORD-99182.'

patterns = {
    'incident_id': r'INC-[0-9]{6}',

Regular expressions for extracting structured entities from raw text

regex text-processing parsing
by Dr. Elena Vasquez 1 tab
python
import time
import requests
from bs4 import BeautifulSoup

session = requests.Session()
session.headers.update({'User-Agent': 'research-bot/1.0'})

Web scraping pipelines with requests and BeautifulSoup

web-scraping beautifulsoup requests
by Dr. Elena Vasquez 1 tab
sql
WITH ordered_events AS (
  SELECT
    customer_id,
    event_time,
    revenue,
    ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY event_time DESC) AS event_rank,

SQL window functions for feature extraction and behavioral ranking

sql window-functions feature-engineering
by Dr. Elena Vasquez 1 tab
python
import great_expectations as gx

context = gx.get_context()
data_source = context.data_sources.add_pandas(name='training_data')
asset = data_source.add_dataframe_asset(name='churn_asset')
batch_definition = asset.add_batch_definition_whole_dataframe('full_dataframe')

Great Expectations checks for dataset health before retraining

great-expectations data-quality mlops
by Dr. Elena Vasquez 1 tab
python
import pandera as pa
from pandera.typing import Series

class ChurnTrainingSchema(pa.DataFrameModel):
    customer_id: Series[int] = pa.Field(unique=True)
    age: Series[int] = pa.Field(ge=18, le=100)

Data validation contracts with Pandera for pipeline reliability

pandera data-validation schema
by Dr. Elena Vasquez 1 tab
python
import mlflow
import mlflow.sklearn
from sklearn.metrics import roc_auc_score

mlflow.set_experiment('customer-churn')

Experiment tracking and model registry workflows with MLflow

mlflow experiment-tracking model-registry
by Dr. Elena Vasquez 1 tab
python
import joblib
from skl2onnx import to_onnx
from skl2onnx.common.data_types import FloatTensorType

joblib.dump(model, 'artifacts/model.joblib')

Serializing models with joblib, pickle, and ONNX tradeoffs

model-serialization joblib onnx
by Dr. Elena Vasquez 1 tab