Skip to content

Instantly share code, notes, and snippets.

View existentialmutt's full-sized avatar

Rafe Rosen existentialmutt

View GitHub Profile
@existentialmutt
existentialmutt / update_standard_todo.rb
Created September 10, 2021 16:34
remove files from standard_todo.yml as they are committed
#!/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__)
@existentialmutt
existentialmutt / Ruby.sublime-syntax
Last active February 19, 2022 21:49
Enhancing Sublime Ruby syntax highlighting with ERB and HAML embedded in heredocs
%YAML 1.2
---
name: Ruby (Custom)
# TODO: unresolved issues
#
# text:
# "p << end
# print me!
# end"
# symptoms:
@existentialmutt
existentialmutt / application.js
Last active August 3, 2022 15:58
Include JS from ruby gem with esbuild
import "my-gem"
@existentialmutt
existentialmutt / irbr.rb
Last active November 25, 2022 00:51
irbr - record irb history to the file of your choice
#!/usr/bin/env ruby
# irbr (short for "IRB Recorder")
#
# Starts an IRB session and appends your history to the specified file
# or "scratch.rb" by default
#
# USAGE irbr.rb output.rb
require "irb"
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 / db_fixtures_export.rake
Last active March 25, 2023 21:10 — forked from kuboon/db_fixtures_export.rake
Generate fixtures from db. Readable by rake db:fixtures:load
# lib/tasks/db_fixtures_export.rake
namespace 'db:fixtures' do
desc "generate fixtures from the current database"
task :export => :environment do
Rails.application.eager_load!
models = defined?(ApplicationRecord) ? ApplicationRecord.descendants : ActiveRecord::Base.descendants
models.each do |model|
puts "exporting: #{model}"
@existentialmutt
existentialmutt / modal_component.html.erb
Last active March 31, 2023 19:22
Modal ViewComponent
<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>