Skip to content

Instantly share code, notes, and snippets.

Avatar

Rafe Rosen existentialmutt

View GitHub Profile
@existentialmutt
existentialmutt / update_standard_todo.rb
Created Sep 10, 2021
remove files from standard_todo.yml as they are committed
View update_standard_todo.rb
#!/usr/bin/env ruby
require 'pathname'
require "tempfile"
require "fileutils"
base = ENV.fetch("STANDARD_UPDATE_BASE") { "$HEAD" }
files = `git diff #{base} --name-only --staged`.split("\n")
app_root = Pathname.new File.expand_path('../../', __FILE__)
View confirmation-modal-controller.js
import { Controller } from "stimulus";
export default class extends Controller {
connect() {
this.element[this.identifier + "-controller"] = this;
}
confirm() {
return new Promise((resolve, reject) => {
this.confirmationResolve = resolve;
View modal_component.html.erb
<div class="modal fade" id="<%= dom_id %>" role="dialog" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<% if header %>
<div class="modal-header">
<%= header %>
<%- if header_close_btn %>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<i class="fa fa-times-circle"></i>
</button>
@existentialmutt
existentialmutt / README.md
Last active Jul 4, 2021 — forked from leastbad/README.md
mrujs w/ cable-car plugin
View README.md

"dependencies": { "cable_ready": "TBD", "mrujs": "TBD" }

@existentialmutt
existentialmutt / application_controller.rb
Created Jun 18, 2021
use Rails::CurrentAttributes with current_user
View application_controller.rb
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
before_action :set_current_user
private def set_current_user
Current.user = current_user
end
end
View slim_select_controller.js
import { Controller } from "stimulus";
import SlimSelect from "slim-select";
export default class extends Controller {
connect() {
this.slimSelect = new SlimSelect({
select: this.element,
addToBody: true
});
}
View synchronous_job.rb
class SynchronousJob < ApplicationJob
def self.perform_later
raise "This job is not designed to be run asynchronously. Please use #perform_now"
end
end
@existentialmutt
existentialmutt / Ruby.sublime-syntax
Last active Oct 24, 2020
Enhancing Sublime Ruby syntax highlighting with ERB and HAML embedded in heredocs
View Ruby.sublime-syntax
%YAML 1.2
---
name: Ruby (Custom)
# TODO: unresolved issues
#
# text:
# "p << end
# print me!
# end"
# symptoms:
@existentialmutt
existentialmutt / polyfills.js
Last active Oct 27, 2020
Polyfills for StimulusReflex in IE11
View polyfills.js
/*
This is the polyfill list from an application that has StimulusReflex / CableReady working in IE 11.
It is almost certainly overkill because some of our non-SR/CR features need polyfills too.
What's definitely needed is `@stimulus/polyfills`, `custom-event-polyfill`, `nodelist-foreach-polyfill`,
`@webcomponents/template`, and at least some of the object and array polyfills.
We also only use a few basic features of SR/CR so fancier stuff like Notifications may require additional polyfills.
*/
@existentialmutt
existentialmutt / confirm-navigation-controller.js
Last active Jun 10, 2020
Confirm Navigation: Rails partial for confirming navigation with a custom modal. Built with Bootstrap and StimulusJS
View confirm-navigation-controller.js
// app/javascript/controllers/confirm-navigation-controller.js
import { Controller } from "stimulus";
import Rails from "rails-ujs";
export default class extends Controller {
static targets = ["confirmationModal"];
connect() {
}