Skip to content

Instantly share code, notes, and snippets.

View chryoung's full-sized avatar

Ewan chryoung

View GitHub Profile
@chryoung
chryoung / tiddlywiki_server.rb
Last active January 11, 2024 19:39
A simple ruby server for TiddlyWiki 5
#!/usr/bin/env ruby
# Install webrick
# gem install webrick
# Then run this script
require 'webrick'
require 'fileutils'
require 'optparse'
options = {
@chryoung
chryoung / field_error_proc.rb
Created April 5, 2022 13:24
Ruby on Rails: Customize field_error_proc to remove div.field_with_errors wrapper
# Save this file to your_rails_project/config/initializers/
# With this code, a form-input-error class can be applied to the input so that it can be styled by tailwindcss or CSS.
# See the original definition on
# https://github.com/rails/rails/blob/c5bf2b4736f2ddafbc477af5b9478dd7143e5466/actionview/lib/action_view/base.rb#L145
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
if html_tag.start_with? '<input'
html_tag.gsub(/class="[^"]+"/, 'class="form-input-error"').html_safe
else
html_tag
end