Skip to content

Instantly share code, notes, and snippets.

View ryenski's full-sized avatar
🎯
Focusing

Ryan Heneise ryenski

🎯
Focusing
  • Austin, TX
View GitHub Profile
@ryenski
ryenski / gist:e36b18e53a50156dbf5cc24b08fee1f3
Last active March 30, 2026 19:06
Error Reporting Patterns — Rails.error API

Error Reporting Patterns

We use Rails' native error reporter (Rails.error) as the single interface for all error and exception reporting. It replaces our previous Honeybadger-specific calls and routes through our RailsErrorSubscriber, which forwards to Rails.logger and the OTel pipeline.


The three APIs

Method When to use
@ryenski
ryenski / grips-tech-debt-2026-03-30.md
Created March 30, 2026 15:59
Grips codebase tech debt analysis — March 2026

Grips Codebase — Tech Debt Analysis

Generated: March 30, 2026
Codebase size: ~1,118 app files, 274 models, 207 controllers, 264 services, 950 tests


1. Dead / Orphaned Code

These files exist but are never referenced outside themselves. Safe to delete after confirmation.

require 'redcarpet'
module MarkdownHandler
def self.erb
@erb ||= ActionView::Template.registered_template_handler(:erb)
end
def self.call(template, source)
_frontmatter, markdown = Page.parse_frontmatter(source, raw: true)
compiled_source = ActionView::OutputBuffer.new(erb.call(template, markdown)).to_s
@ryenski
ryenski / markdown_helper.rb
Last active June 2, 2025 22:13
Markdown Helper
require 'redcarpet'
require 'redcarpet/render_strip'
module MarkdownHelper
def markdown(str)
html_renderer.render(str).html_safe
end
def plain_text(str)
strip_down_renderer.render(str).html_safe
@ryenski
ryenski / i18n-best-practices.md
Created October 1, 2024 17:46
I18n Best Practices in Rails

I18n Best Practices

Use human-readable keys

Prefer natural language over abstracted strings for language keys. This helps to make the views easier to read and understand.

Take advantage of the fact that spaces are legal in YAML keys:

Examples

# Bad
t('.all_label')
@ryenski
ryenski / db.rake
Created May 28, 2024 16:33
Protect production environment from destructive rake tasks
desc 'Raise exception if used in production'
task protect_prod: [:environment] do
raise 'This task cannot be run in production' if Rails.env.production?
end
['db:drop', 'db:reset', 'db:seed'].each do |t|
Rake::Task[t].enhance ['protect_prod']
end
@ryenski
ryenski / json-to-csv-with-jq.md
Last active April 11, 2024 20:14
Convert json to csv with jq @csv filter

To convert json to csv with headers using jq and the @csv filter.

jq -r '[first|keys_unsorted] + map([.[]]) | .[] | @csv' example.json > converted.csv

This would work on a simple json structured like:

[
@ryenski
ryenski / one_time_code.rb
Created December 12, 2022 23:58
A small script to generate memorable one-time passcodes.
# A small script to generate memorable one-time codes.
#
# OneTimeCode.generate
# => "ubahow-idea-easy-aveda"
class OneTimeCode
def initialize(length = 12)
@length = length
@mod_result = MOD_RESULT.sample
end
@ryenski
ryenski / checkout.rb
Last active December 12, 2022 23:59
Stripe Webhooks Controller
# This example follows a Stripe webhook through the application life cycle.
# In this case, a customer has created a Checkout, which is an object in our application that acts like a shopping cart.
# It relates to the products that are being purchased and encapsulates the customer's existing record, or the data required to create a new customer.
class Checkout < ApplicationRecord
include Amountable
include BtcpayInvoice
include StripePaymentIntent
belongs_to :user, optional: true
{"version":1,"resource":"file:///Users/ryanheneise/Projects/api/src/services/fees/index.js","entries":[{"id":"DXVN.js","timestamp":1667270770299},{"id":"VJk1.js","timestamp":1667270856905},{"id":"pi2q.js","timestamp":1667271038502}]}