Skip to content

Instantly share code, notes, and snippets.

@Sillson
Sillson / name_me_a_widget.rb
Last active November 12, 2015 18:12
Output an array of widget names & locations
class OrphanAnnie
class << self
def perform
fake_orphan_locations = mom_is_that_you
write_to_loggers("#{fake_orphan_locations}")
rehome_fake_orphans
write_to_loggers("There are #{Widget.orphans.count} orphans left.")
Resque.enqueue(WidgetCleanupJob)
end
@g5codyswartz
g5codyswartz / name_me_a_widget.rb
Last active December 31, 2015 08:30 — forked from Sillson/name_me_a_widget.rb
Output an array of widget names & locations
class OrphanAnnie
def self.perform
lost_souls = mom_is_that_you
write_to_loggers("#{lost_souls}")
end
def self.mom_is_that_you
names = Widget.orphans.select {|i| !i.parent_widget.nil?}
web_pages = names.map {|w|
self.get_infos(w)
@Sillson
Sillson / GetOutMyRailsConsole
Last active August 30, 2017 03:44
Boot sorry suckers out of a heroku rails console
## Boot chumps from your heroku free dynos
## PS the app
heroku ps -a [APP]
## Find that one-off process, snag that pid
=== run: one-off processes (1)
run.4570 (Free): up 2016/03/03 10:01:16 -0800 (~ 8m ago): bin/rails console
## Tossed like a chump
@thescubageek
thescubageek / find_matching_settings.rb
Last active September 14, 2016 22:01
Finds settings (and corresponding owners) matching string pattern
## G5 Content Management System
def find_setting_value(target)
Setting.where(Setting.arel_table[:value].matches("%#{target}%"))
end
def find_setting_value_widgets(target)
find_setting_value(target).map do |setting|
setting.owner
end.uniq
@thescubageek
thescubageek / repair_drop_targets.rb
Created September 14, 2016 18:38
Repairs bad drop targets for CMS
def repair_drop_targets(html_id, widgets=[])
bad = Website.all.select do |web|
!web.website_template.blank? && (
web.website_template.drop_targets.find_by_html_id(html_id).blank? ||
web.website_template.drop_targets.find_by_html_id(html_id).widgets.blank?)
end
bad.each do |web|
wt = web.website_template
dt = wt.drop_targets.find_by_html_id(html_id)