Skip to content

Instantly share code, notes, and snippets.

View dcyoung-dev's full-sized avatar
🥞
Full Stacking

David Young dcyoung-dev

🥞
Full Stacking
View GitHub Profile
@dcyoung-dev
dcyoung-dev / Procfile.dev
Last active June 18, 2021 10:56
Development Procfile
web: bundle exec rails server
worker: bundle exec sidekiq
webpack: bundle exec bin/webpack-dev-server
@dcyoung-dev
dcyoung-dev / capybara.rb.sample
Last active January 28, 2022 10:44
Setup script and templates for installing and configuring RSpec
require 'capybara'
@dcyoung-dev
dcyoung-dev / .tool-versions
Last active February 21, 2022 16:57
Rails Scripts
ruby 3.0.1
nodejs 16.0.0
@mixin for-size($range) {
$phone-upper-boundary: 37.5rem;
$tablet-portrait-upper-boundary: 56.25rem;
$tablet-landscape-upper-boundary: 75rem;
$desktop-upper-boundary: 112.5rem;
@if $range == phone-only {
@media (max-width: #{$phone-upper-boundary - 1}) { @content; }
} @else if $range == tablet-portrait-up {
@media (min-width: $phone-upper-boundary) { @content; }
module TurboFrameHelpers
def turbo_frame_id(*ids)
ids.map { |id| id.respond_to?(:to_key) ? ActionView::RecordIdentifier.dom_id(id) : id }.join("_")
end
end
RSpec.configure do |config|
config.include TurboFrameHelpers
end
@dcyoung-dev
dcyoung-dev / auto_save_controller.js
Created March 23, 2023 10:11
Using lodash debounce function in a Stimulus controller
import {Controller} from "@hotwired/stimulus"
import {debounce} from "lodash/function";
// Connects to data-controller="auto-save"
export default class extends Controller {
initialize() {
this.autosave = debounce(this.autosave, 200).bind(this)
}
autosave(event) {
@dcyoung-dev
dcyoung-dev / active_link_to.rb
Last active April 10, 2023 16:54
An `active_link_to` helper that adds the `.active` class and sets `aria-current="page"`