Skip to content

Instantly share code, notes, and snippets.

View fractaledmind's full-sized avatar

Stephen Margheim fractaledmind

View GitHub Profile
@fractaledmind
fractaledmind / checkbox_select_all_controller.js
Created June 18, 2021 14:37
Fancy replace+add ActiveStorage file-field widget (Stimulus, ActiveStorage, Rails)
import { Controller } from 'stimulus'
export default class extends Controller {
static targets = ['checkboxAll', 'checkbox']
initialize () {
this.toggle = this.toggle.bind(this)
this.refresh = this.refresh.bind(this)
}
@fractaledmind
fractaledmind / acidic_jobs_sandbox.rb
Last active July 22, 2021 13:34
A script to demonstrate the initial basic implemtation of AcidicJobs
# frozen_string_literal: true
# GEMS -------------------------------------------------------------------------
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
@fractaledmind
fractaledmind / core_extensions__date__ranges.rb
Created May 12, 2021 14:16
Example Dashboard with basic time range filtering
module CoreExtensions
module Date
module Ranges
def all_yesterday
yesterday.all_day
end
def all_last_week
last_week.all_week
end
@fractaledmind
fractaledmind / nested_form_controller.js
Created March 5, 2021 11:24
Rails CRUD has_many rich_texts
import { Controller } from "stimulus"
export default class extends Controller {
static targets = [ "insertionPoint", "template", "fieldsWrapper" ]
connect() {
this.element[this.identifier] = this
}
add_association(event) {
@fractaledmind
fractaledmind / jobbable_concern.rb
Created March 1, 2021 09:09
This concern allows model instances to run async jobs that depend on them. Calling #async_method_name will trigger the MethodNameJob
module Jobbable
extend ActiveSupport::Concern
# This concern allows model instances to run async jobs that depend on them.
# Calling #async_method_name will trigger the MethodNameJob
PREFIX = "async_"
included do
def method_missing(method_name)
.combo {
display: block;
margin-bottom: 1.5em;
// max-width: 400px;
position: relative;
}
.combo::after {
border-bottom: 2px solid rgba(0,0,0,.5);
border-right: 2px solid rgba(0,0,0,.5);
<div class="card">
<div class="card-header">
<h3 class="card-title">
<%= notification.to_notification.in_app_subject %>
</h3>
</div>
<div class="card-body">
<%= notification.to_notification.in_app_body %>
</div>
</div>
@fractaledmind
fractaledmind / freezable_association.rb
Last active February 24, 2021 10:23
Allow AR models to have a "freezable" association to another model
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
@fractaledmind
fractaledmind / hyperspeed.rb
Created June 26, 2020 19:09
If you've ever been frustrated by ERB or HAML's inability to easily compose or transform your partials/components, then `hyperspeed` is likely for you. Or, if you've simply wanted to write your markup in pure Ruby with the simplest possible methods, `hyperspeed` is here to help. The `Hyperspeed` module provides only two methods: `define` and `re…
module Hyperspeed
class Error < StandardError; end
def self.define(&block)
definition_proxy = DefinitionProxy.new
definition_proxy.evaluate(&block)
end
# rubocop:disable Metrics/AbcSize
def self.render(ast = nil) # &block
@fractaledmind
fractaledmind / tailwind-utilities-important.css
Last active September 21, 2019 13:51
Default Tailwind utility classes with the !important flag added (for easier integration with Bootstrap)
This file has been truncated, but you can view the full file.
.sr-only {
position: absolute !important;
width: 1px !important;
height: 1px !important;
padding: 0 !important;
margin: -1px !important;
overflow: hidden !important;
clip: rect(0, 0, 0, 0) !important;
white-space: nowrap !important;
border-width: 0 !important