Skip to content

Instantly share code, notes, and snippets.

# celery_config.py
"""
Celery Configuration Module
This module provides the core Celery configuration for handling long-running tasks
in a FastAPI application with Redis as broker and result backend.
Key Features:
- Redis broker configuration with connection pooling
- Task routing and queue management
import os
import json
from datetime import datetime, timedelta
from typing import Optional, Dict, Any
from dataclasses import dataclass
from functools import lru_cache
import threading
import boto3
from botocore.exceptions import ClientError
@scscodes
scscodes / eslint_mui_deprecation.md
Created June 26, 2025 12:42
Context for React/Next-based applications which may experience breaking changes for certain MUI verisons.

ESLint Rule: Prevent Deprecated MUI Grid Props (v7+)

Material UI v7 removed the following props from the Grid component:

  • item, container, xs, sm, md, lg, xl, spacing

To enforce the new API (Grid for layout, GridCol for columns/items, gap for spacing, span/md/lg for breakpoints), use this ESLint rule in your config.


Why?

@scscodes
scscodes / fastapi streaming response.md
Created May 16, 2025 11:38
Streaming response concepts, patterns and related conditions

FastAPI Streaming Cheat‑Sheet

1  Why stream?

  • Lower latency – send data as soon as it’s ready.
  • Reduced memory footprint – no need to build the whole response in RAM.
  • Natural fit for long‑running jobs – DB cursor paging, ML inference, log tails, etc.

@scscodes
scscodes / load state concept.md
Last active May 14, 2025 17:29
Rxjs wrapper to improve UX when streaming API calls directly into the template.

Angular LoadState Utility

Lightweight helper that converts any Observable<T> into an Observable<LoadState<T>>, packaging status, data, and error in a single, UI‑friendly payload.


1. Types

export type LoadStatus = 'idle' | 'loading' | 'empty' | 'success' | 'error';
@scscodes
scscodes / img_stitch.py
Created February 11, 2025 01:43
Iterate over images in given directory, joining them vertically into a single image.
from PIL import Image
import os
def join_images_vertically(input_dir='img', output_file='combined_image.png'):
"""
Combines all images in the input directory into a single vertical image.
Args:
input_dir (str): Directory containing input images
output_file (str): Name of the output file
@scscodes
scscodes / eslint.config.js
Created January 31, 2025 02:06
Angular +19 with ESlint +9
import globals from "globals";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import tsEslintPlugin from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import angularPlugin from '@angular-eslint/eslint-plugin';
import angularTemplatePlugin from "@angular-eslint/eslint-plugin-template";
import angularTemplateParser from "@angular-eslint/template-parser";
import importPlugin from 'eslint-plugin-import';
import unusedPlugin from 'eslint-plugin-unused-imports';
@scscodes
scscodes / real-gdp.csv
Created October 10, 2024 13:27
Real GDP data, 1990-2024, from FRED
DATE GDPC1
1990-01-01 10047.386
1990-04-01 10083.855
1990-07-01 10090.569
1990-10-01 9998.704
1991-01-01 9951.916
1991-04-01 10029.51
1991-07-01 10080.195
1991-10-01 10115.329
1992-01-01 10236.435
@scscodes
scscodes / readme.md
Created October 8, 2024 20:09
Node + Pm2 poc

tldr

given an existing node install and project files (server.js), use pm2 to automatically start it after system boot.
this was completed on a raspberry pi 3 for educational purposes.

globally install pm2: sudo npm install -g pm2 start node: pm2 start server.js start on boot: pm2 startup + pm2 save

We can't make this file beautiful and searchable because it's too large.
Customer ID,Age,Gender,Loyalty Member,Product Type,SKU,Rating,Order Status,Payment Method,Total Price,Unit Price,Quantity,Purchase Date,Shipping Type,Add-ons Purchased,Add-on Total
1000,53,Male,No,Smartphone,SKU1004,2,Cancelled,Credit Card,5538.33,791.19,7,3/20/2024,Standard,"Accessory,Accessory,Accessory",40.21
1000,53,Male,No,Tablet,SKU1002,3,Completed,Paypal,741.09,247.03,3,4/20/2024,Overnight,Impulse Item,26.09
1002,41,Male,No,Laptop,SKU1005,3,Completed,Credit Card,1855.84,463.96,4,10/17/2023,Express,,0
1002,41,Male,Yes,Smartphone,SKU1004,2,Completed,Cash,3164.76,791.19,4,8/9/2024,Overnight,"Impulse Item,Impulse Item",60.16
1003,75,Male,Yes,Smartphone,SKU1001,5,Completed,Cash,41.5,20.75,2,5/21/2024,Express,Accessory,35.56
1004,41,Female,No,Smartphone,SKU1001,5,Completed,Credit Card,83,20.75,4,5/26/2024,Standard,"Impulse Item,Accessory",65.78
1005,25,Female,No,Smartwatch,SKU1003,3,Completed,Paypal,7603.47,844.83,9,1/30/2024,Overnight,,0
1005,25,Female,No,Laptop,SKU1005,3,Completed,Debit Card,4175.64,463.96