CI/CD

GitHub Actions: Deploy over SSH on Push YAML

A workflow that updates a folder on your server whenever you push to master. Works for WordPress themes, static sites and small PHP apps.

on:
  push:
    branches: [master]
jobs:
  deploy:
    runs-on: ubuntu-latest
GitHub Actions SSH Git

Docker

Docker Compose: Spring Boot + React + MongoDB YAML

One file to run a Spring Boot API, a React front end and MongoDB together, with a persistent volume and a private network.

services:
  mongodb:
    image: mongo:7
  backend:
    build: ./backend
  frontend:
    build: ./client
Docker Compose Spring Boot React MongoDB

PHP

PHP PDO Connection and Query Helper PHP

A safe PDO setup (exceptions, real prepared statements, UTF-8) and a one-line helper for parameterised queries.

$pdo = new PDO($dsn, $user, $pass, [
    PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_EMULATE_PREPARES => false,
]);
PHP 8 PDO MySQL
PHP Auth and Role Middleware for JSON APIs PHP

Two functions, requireAuth() and requireRole(), that protect any endpoint in one line and answer with proper 401 and 403 JSON errors.

function requireRole(string ...$roles): array {
    $user = requireAuth();
    if (!in_array($user['role'], $roles, true)) { ... }
PHP 8 Sessions

Python

Python Scraper: Requests + BeautifulSoup to CSV Python

A polite scraper skeleton: session with a user agent, delays between requests, parsing with CSS selectors and CSV output.

for url in urls:
    soup = BeautifulSoup(session.get(url, timeout=20).text, 'html.parser')
    for item in soup.select('.item'):
        writer.writerow(...)
Python 3 Requests BeautifulSoup

Spring

Spring Cloud Gateway Routes with Eureka YAML

Gateway configuration that routes /api/* paths to services discovered in Eureka, with load balancing between instances.

routes:
  - id: products
    uri: lb://product-service
    predicates:
      - Path=/api/products/**
Spring Boot 3 Spring Cloud Gateway Eureka

WordPress

WordPress REST API: Create a Draft Post with curl Bash

Create a draft post with title, content, excerpt and category from any script or automation tool, authenticated with an Application Password.

curl -X POST https://example.com/wp-json/wp/v2/posts 
  -u "user:app-password" 
  -H "Content-Type: application/json" 
  -d '{"status":"draft", ...}'
WordPress REST API curl Application Passwords