Skip to content

Instantly share code, notes, and snippets.

View existentialmutt's full-sized avatar

Rafe Rosen existentialmutt

View GitHub Profile

Keybase proof

I hereby claim:

  • I am existentialmutt on github.
  • I am existentialmutt (https://keybase.io/existentialmutt) on keybase.
  • I have a public key whose fingerprint is 644B 7A07 984F 1E10 DEA9 7DB2 5C41 B88A F0B3 3FF3

To claim this, I am signing this object:

@existentialmutt
existentialmutt / user.behaviors
Created October 4, 2014 04:30
Light Table User Behaviors
;; User behaviors
;; -----------------------------
;; Behaviors are stored as a set of diffs that are merged together
;; to create the final set of functionality that makes up Light Table. You can
;; modify these diffs to either add or subtract functionality.
;;
;; Behaviors are added to tags, objects with those tags then automatically gain
;; whatever logic the behavior imparts. To see a list of user-level behaviors,
;; start typing a word related to the functionality you want in between the square
;; brackets (e.g. "theme").
@existentialmutt
existentialmutt / rails.cap
Last active December 6, 2016 18:16 — forked from joost/deploy.rb
Capistrano 3 rails console tasks and log tailing tasks
# Place in lib/capistrano/tasks/rails.cap and require it in your Capfile
# See: https://gist.github.com/existentialmutt/c904d6e55cd09dda81ea9751d2e66e6d
# Adapted to work with RVM installed to /usr/local
namespace :rails do
desc "tail rails logs"
task :tail_logs do
on roles(:app) do
execute "tail -f #{shared_path}/log/#{fetch(:rails_env)}.log"
end
end
@existentialmutt
existentialmutt / index.haml
Last active June 10, 2020 20:53
SortableList. Harness for applying SortableJS to resources generically.
-# app/views/thingies/index.haml
%table
%thead
%tr
%th
%th Thingy Name
%tbody#thingyList{data: {sortable_list_url: reorder_thingies_path} }
- @thingies.order(:position).each do |thingy|
%tr{data: {sortable_item_id: thingy.id, sortable_item: true}}
%td
@existentialmutt
existentialmutt / confirm-navigation-controller.js
Last active June 10, 2020 21:07
Confirm Navigation: Rails partial for confirming navigation with a custom modal. Built with Bootstrap and StimulusJS
// 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() {
}
@existentialmutt
existentialmutt / polyfills.js
Last active October 27, 2020 13:35
Polyfills for StimulusReflex in IE11
/*
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.
*/
import { Controller } from "stimulus";
import SlimSelect from "slim-select";
export default class extends Controller {
connect() {
this.slimSelect = new SlimSelect({
select: this.element,
addToBody: true
});
}
@existentialmutt
existentialmutt / application_controller.rb
Created June 18, 2021 17:48
use Rails::CurrentAttributes with current_user
# 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
@existentialmutt
existentialmutt / README.md
Last active July 4, 2021 00:35 — forked from leastbad/README.md
mrujs w/ cable-car plugin

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

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;