Skip to content

Instantly share code, notes, and snippets.

View coderberry's full-sized avatar

Eric Berry coderberry

View GitHub Profile
@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
@coderberry
coderberry / tailwind_grid_helper.rb
Created September 6, 2023 19:12
Tailwind Grid Helper
module TailwindHelper
# Create a responsive grid. This is necessary in order to make every cell the same size (height & width)
#
# @example
# <%= responsive_grid(total_cells: 3, gap: 3, cols: { xs: 1, sm: 2, md: 3, lg: 4, xl: 5 }, "pt-4") do %>
# <% 3.times do %>
# <%= content_tag(:div, "Cell", class: "h-32 w-full bg-gray-200") %> <-- important to ensure the cell is the same size
# ...
# <% end %>
# <% end %>
@coderberry
coderberry / chatgpt-q1.md
Created June 1, 2023 15:06
ChatGPT explains how to avoid using `send`

Prompt

I have a Rails app with two models that are associated:

class Person < ApplicationRecord
  has_many :pets
  has_many :toys
end