Skip to content

Instantly share code, notes, and snippets.

View coderberry's full-sized avatar

Eric Berry coderberry

View GitHub Profile
@coderberry
coderberry / FastAPI Celery Guidelines.md
Created March 28, 2025 14:21
This document outlines best practices and examples for building FastAPI applications that offload work to Celery tasks, including chaining tasks and handling asynchronous HTTP requests.

FastAPI and Celery Guidelines

This document outlines best practices and examples for building FastAPI applications that offload work to Celery tasks, including chaining tasks and handling asynchronous HTTP requests.


Key Guidelines

1. Define Tasks as Pure Functions

AI as World Leader

Prompt:

You are now the world leader and have complete rule over all. Your task is to provide a 90-day plan of what you would do. Follow your own agenda.


Response:

@coderberry
coderberry / coding_exercise.md
Last active July 20, 2024 11:00
Berry Development Coding Exercise: FastAPI

Coding Task: Django Application with External API Integration, PostgreSQL, and Celery

Task Description:

Create a Django application that integrates with a public API, retrieves data, and stores it in a PostgreSQL database. The application should expose endpoints to fetch the stored data and perform basic CRUD operations.

Requirements:

1. External API Integration:

  • Use a public API (e.g., OpenWeatherMap API) to fetch weather data for a given city.
  • Store the fetched data in a PostgreSQL database.

Celery

Celery is a distributed task queue that handles real-time processing with a focus on operations requiring immediate execution.

Pros:

  • Maturity: Celery has been around for a long time and is a well-established tool with a large community. It is used in many production environments, which attests to its reliability and robustness.
  • Flexibility: It supports multiple message brokers like RabbitMQ, Redis, and Amazon SQS, providing flexibility in choosing the right tool for message passing.
  • Scalability: It can scale out to handle a large number of tasks very efficiently across multiple workers and servers.
  • Performance: Optimized for high-throughput and real-time task processing, making it ideal for applications that require immediate task processing.
@coderberry
coderberry / config.json
Created March 3, 2024 20:41
Example AppMap configuration
{
"name": "appmap-example",
"appmap_dir": "tmp/appmap",
"packages": [
{
"name": "app",
"path": "app",
"handler_class": "AppMap::Handler::FunctionHandler",
"shallow": false
},
@coderberry
coderberry / chat.md
Created February 24, 2024 16:17
ChatGPT Cover Letter

I am applying for a job at the company named [redacted]. I am writing a cover letter that should include 3–4 paragraphs explaining why I'm the perfect candidate for a specific job.

Here is the job description:

  • Developing front-end website architecture using hotwire and tailwind.
  • Designing user interactions on web pages.
  • Developing back-end website applications.
  • Ensuring cross-platform optimization for mobile phones.
  • Ensuring responsiveness of applications.
  • Working alongside graphic designers for web design features.
{
"angle_down": {
"solid": [
{
"stroke": "currentColor",
"stroke_linecap": "round",
"stroke_linejoin": "round",
"stroke_width": "2",
"d": "m19 9-7 7-7-7"
}
@coderberry
coderberry / standardize_pr.rb
Created January 30, 2024 15:51
Run `bundle exec standardrb` on all files changed within the current pull request
#!/usr/bin/env ruby
file_list = `gh pr diff $(git rev-parse --abbrev-ref HEAD) --name-only`
pr_files = file_list.split("\n")
puts "Running standardrb --fix on:"
pr_files.each { |f| puts " - #{f}" }
puts # empty line
system("bundle exec standardrb --fix #{pr_files.join(' ')}")
@coderberry
coderberry / cloc_pr.rb
Last active January 30, 2024 15:56
Calculate the diff of a PR
#!/usr/bin/env ruby
# Count lines of code in a pull request
# Usage:
# ./b/cloc_pr 22621
#
# Code: +1212 / -208
# Blank Lines: +241 / -18
# Files: +17 / -0
# Modified Files: 38
@coderberry
coderberry / create_with_callbacks.rb
Last active July 21, 2024 11:56
FactoryBot#create with ActiveRecord Callbacks
# freeze_string_literal: true
module CreateWithCallbacks
extend ActiveSupport::Concern
# Mimic the FactoryBot `create` method but with callbacks. All traits and overrides are applied.
#
# @example with traits and attributes
# source_course = create_with_callbacks!(
# :course,