This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller } from "@hotwired/stimulus" | |
import { DirectUpload } from "@rails/activestorage" | |
// This is a very rough hack to allow a file upload field that we'd like to be a direct upload | |
// but is loading into the dom in a way that the normal form submit event is clobbered by other | |
// processes (like hotwire). | |
// | |
// This is made based off of the ActiveStoreage guides for integrating direct uploads for other | |
// JS frameworks. The biggest difference here is when the user picks a file, the file is immedidatly | |
// uploaded to the sever. More things in this controller should be fleshed out in the future such |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
branch_prefix = "pt_" | |
branches_to_keep = [] | |
cmd = `git branch --merged master` | |
branches = cmd.split("\n").map(&:strip).select{ |b| b.start_with?(branch_prefix) && !branches_to_keep.include?(b) } | |
branches.each do |branch| | |
`git branch -D #{branch}` | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
unicorn_worker_memory_limit = 460_000 | |
loop do | |
begin | |
# unicorn workers | |
# | |
# ps output line format: | |
# 31580 275444 unicorn_rails worker[15] -c /data/github/current/config/unicorn.rb -E production -D |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post | |
has_many :cat_relations | |
has_many :categories, through: :cat_relations | |
end | |
class Category | |
has_many :cat_relations | |
has_many :posts, through: :cat_relations | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Your code you include somewhere | |
module MySpecialCodeBlock | |
def foo(x) | |
puts "Twice x is: #{x*2}" | |
super | |
end | |
end | |
# From a libary | |
class TheRealClass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PaperTrail | |
module Model | |
# Creates and updated_by attributes on all paper trailed models. If given | |
# an ActiveRecord instance, PaperTrail.whodunnit will be set as | |
# "ModelName::Id". Calling updated_by will return the ActiveRecord object. | |
module InstanceMethods | |
def updated_by=(updater) | |
PaperTrail.whodunnit = PaperTrail::UpdatedByParser.to_s(updater) | |
end |