Skip to content

Instantly share code, notes, and snippets.

View seanharmer's full-sized avatar

Sean Harmer seanharmer

View GitHub Profile
@seanharmer
seanharmer / index.html
Created February 6, 2024 14:12
Rive Stimulus
<canvas
data-controller="rive"
data-rive-url-value="<%= asset_path("button1.riv") %>"
data-rive-state-machines-value="State Machine 1"
class="mt-16 w-full aspect-video bg-black"
>
</canvas>
{
"version": 3,
"configurePresets": [
{
"name": "configure-base",
"hidden": true,
"generator": "Ninja",
"cacheVariables": {
"SERENITY_BUILD_EXAMPLES": "ON",
"SERENITY_BUILD_TESTS": "ON"
@seanharmer
seanharmer / membership_product.rb
Last active May 6, 2022 09:49
Example usage of new delegated_type facility
class MembershipProduct < ApplicationRecord
include Sellable
# Other stuff...
end
@seanharmer
seanharmer / gist:f0fb73170853c5628613ef90ed3b540c
Created December 10, 2020 08:36
Rails font awesome xlink
# app/helpers/application_helper.rb
module ApplicationHelper
def declare_fa_icon(options, anchor_name)
fa_icon(options, data: { 'fa-symbol': anchor_name })
end
def use_fa_icon(anchor_name, text)
%Q(<svg class="icon-fa-xs"><use xlink:href="##{anchor_name}"></use></svg>#{text}).html_safe
end
# Put in config/initializers/html_sanitizer.rb
#
# See https://github.com/rails/rails-html-sanitizer/blob/master/lib/rails/html/scrubbers.rb
# for more help on how the PermitScrubber works and the functions you can override.
class CustomScrubber < Rails::Html::PermitScrubber
def initialize
super
puts("CustomScrubber says hi!")
self.tags = %w( script iframe figure figcaption action-text-attachment )