Skip to content

Instantly share code, notes, and snippets.

View coderberry's full-sized avatar

Eric Berry coderberry

View GitHub Profile
@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
# USAGE: `ruby ask_cpteeves.rb`
# Type "exit" to quit
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'ruby-openai'
gem 'pry'
gem 'tty-prompt'
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "2.7.6"
# Authorization framework for Ruby/Rails application
# [https://github.com/palkan/action_policy]
gem "action_policy", "~> 0.6.4"
# Action Policy integration for GraphQL-Ruby
# Shared collection of (mostly Arel) class-level helpers for working with advanced
# SQL selections.
#
# Source: https://github.com/ManifoldScholar/manifold/blob/84625d40af628646453668be028dabc2aa249516/api/app/models/concerns/arel_helpers.rb#L313
#
# Required rubygem: 'dux'
#
# rubocop:disable Style/CharacterLiteral
# rubocop:disable Style/StringLiterals
# @see https://www.postgresql.org/docs/9.5/static/functions-json.html JSON functions and operators in PostgreSQL
@coderberry
coderberry / github-review-toggle-checkboxes.js
Created December 15, 2022 19:12
Inserts a button that can toggle the "viewed" checkboxes when reviewing a PR on Github.
const url = document.URL;
class ReviewToggle {
insertButton() {
const parentElement = document.querySelector(".pr-review-tools");
let button = document.querySelector('#boost-toggle-checkboxes');
if (!button) {
button = document.createElement("button");
button.id = "boost-toggle-checkboxes";
}
@coderberry
coderberry / ci.yml
Created August 14, 2020 16:30
Using GitHub Actions for CI (rspec + rubocop)
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
RAILS_ENV: test
### Keybase proof
I hereby claim:
* I am coderberry on github.
* I am coderberry (https://keybase.io/coderberry) on keybase.
* I have a public key ASDxOxY4XXIxGp-zouupDGuL3A-bGhziJZ3e6STSnBQaVwo
To claim this, I am signing this object: