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
# lib/tasks/db.rake | |
namespace :db do | |
desc "Dumps the database to db/APP_NAME.dump" | |
task :dump => :environment do | |
cmd = nil | |
with_config do |app, host, db, user| | |
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
end | |
puts cmd |
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
namespace :clean do | |
task :snags => :environment do | |
Location.all.each do |loc| | |
@pages = loc.website.web_page_templates | |
@pages.each do |i| | |
i.update_attribute(:parent_id, nil) if i.parent_id? | |
end | |
nav_id = (GardenWidget.find_by name: "Navigation").id | |
@nav_setting = (loc.website.widgets.find_by garden_widget_id: nav_id).navigation.object |
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
# How to find duplicate website objects in a CMS! | |
#map an array of all websites 'owner_id' | |
loc_ids = Website.all.map {|web| web.owner_id} | |
#returns the duplicates | |
loc_ids.select{ |id| loc_ids.count(id) > 1}.uniq |
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 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 |
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
</style><script>function insertAfter(referenceNode, newNode) { | |
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); | |
console.log(referenceNode.parentNode); | |
} | |
var div = document.getElementsByClassName("row-grid"); | |
var locationName = "[ENTER LOCATION NAME]"; | |
var locationCity = "[ENTER LOCATION CITY]"; | |
var locationState = "[ENTER LOCATION STATE]"; |
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
echo "Downloading the latest backup from the Core Servers" | |
echo | |
curl --insecure -O https://wherever-bz2-backup-origin.sql | |
echo "Download complete" | |
echo | |
echo "Unzipping this beast, and plopping it right in the core db on AWS" | |
echo | |
bunzip2 < backup.sql.bz2 | mysql -u [USER] -pw[PW] --host [HOST] [DBNAME] |
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
install.packages( | |
lib = lib <- .libPaths()[1], | |
pkgs = as.data.frame(installed.packages(lib), stringsAsFactors=FALSE)$Package, | |
type = 'source' | |
) |
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
CREATE SERVER [SERVER_NAME] | |
FOREIGN DATA WRAPPER postgres_fdw | |
OPTIONS (host '[YOUR_HOST]', port '[PORT]', dbname '[DB_NAME]', sslmode 'require'); | |
CREATE USER MAPPING FOR [DB_USER] | |
SERVER [SERVER_NAME] | |
OPTIONS (user '[FOREIGN_USER]', password '[FOREIGN_PW]'); |
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
CREATE OR REPLACE VIEW public.active_locks AS | |
SELECT t.schemaname, | |
t.relname, | |
l.locktype, | |
l.page, | |
l.virtualtransaction, | |
l.pid, | |
l.mode, | |
l.granted | |
FROM pg_locks l |
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
do | |
$$ | |
declare | |
l_rec record; | |
begin | |
for l_rec in (select foreign_table_schema, foreign_table_name | |
from information_schema.foreign_tables) loop | |
execute format('drop foreign table %I.%I cascade', l_rec.foreign_table_schema, l_rec.foreign_table_name); | |
end loop; | |
end; |
OlderNewer