Skip to content

Instantly share code, notes, and snippets.

View coderberry's full-sized avatar

Eric Berry coderberry

View GitHub Profile
@coderberry
coderberry / coding_exercise.md
Created July 9, 2024 15:26
Berry Development Coding Exercise: FastAPI

Coding Task: FastAPI Application with External API Integration and PostgreSQL

Task Description:

Create a small FastAPI 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 December 20, 2023 19:52
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,
@coderberry
coderberry / extensions.json
Created December 11, 2023 18:00
Rails IDE VSCode Extensions
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"LoranKloeze.ruby-rubocop-revived",
"castwide.solargraph",
"jemmyw.rails-fast-nav",
"MateuszDrewniak.ruby-test-runner",
@coderberry
coderberry / ai-challenge-prompt.md
Last active November 15, 2023 22:17
Ruby AI Challenge

You are an expert software engineer that understands all aspects of the Ruby programming language (version 3).

Consider the following tree structure:

.
├── 1
│   ├── 1.1
│   │   ├── 1.1.1
│ │ ├── 1.1.2