Skip to content

Instantly share code, notes, and snippets.

@cec
cec / gist:77cc762c4b9bdf4577d42c7607b6f65e
Created June 25, 2021 09:24
Watch JSON logs pretty-printed for human readability
tail -100f log-file.json | jq --unbuffered
@cec
cec / MultiTextValidator
Created September 11, 2013 16:07
Rails 3.2 - Custom validator class on parent model, clashing with validates_associated :child_models
# encoding: UTF-8
# This validator checks common validation rules for all models having associated text models
class MultiTextValidator < ActiveModel::Validator
cattr_reader :error_messages
@@error_messages = {
italian_missing: 'activemodel.errors.event.texts.italian_missing',
non_unique_languages: 'activemodel.errors.event.texts.non_unique_languages',
}
@cec
cec / solr_deploy_interactions.rb
Created May 3, 2013 10:01
Capistrano Tasks to setup and interact with SolR and SunSpot
namespace :deploy do
# Ask whether to reindex before restarting Passenger
task :restart, :roles => :app, :except => {:no_release => true} do
solr.reindex if 'y' == Capistrano::CLI.ui.ask("\n\n Should I reindex all models? (anything but y will cancel)")
run "touch #{File.join(current_path, 'tmp', 'restart.txt')}"
end
desc 'create shared data and pid dirs for Solr'
task :setup_solr_shared_dirs do
# conf dir is not shared as different versions need different configs