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
faye: rackup private_pub.ru -s thin -E development | |
search: bundle exec rake sunspot:solr:run | |
search_test: bundle exec rake sunspot:solr:run RAILS_ENV=test | |
neo4j: bundle exec rake neo4j:console | |
rescue: bundle exec rake resque:work QUEUE='import_queue' |
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
#!/bin/bash | |
## START PRECOMMIT HOOK | |
# git commit .... <-- run with check | |
# NOCHECK=1 git commit ... <-- run without check | |
if [ ! "${NOCHECK}" ]; then | |
files_modified=`git status --porcelain | egrep "^(A |M |R ).*" | awk ' { if ($3 == "->") print $4; else print $2 } '` | |
for f in $files_modified; do | |
echo "Checking ${f}..." | |
if grep --color -n "console.log" $f; then |
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
// <% environment.context_class.instance_eval { include Rails.application.routes.url_helpers } %> |
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 :db do | |
desc 'Create db backup' | |
task :backup => :environment do | |
db_config = Rails.configuration.database_configuration[Rails.env] | |
username = db_config['username'] | |
password = db_config['password'] | |
database = db_config['database'] | |
bak_folder = "#{Dir.home}/backups" |
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
--type-add=ruby=.haml,.rake, .slim, .feature | |
--type-add=css=.less,.scss, .sass | |
--type-add=js=.coffee | |
--ignore-dir=neo4j | |
--ignore-dir=tmp | |
--ignore-dir=coverage | |
--ignore-dir=log | |
--ignore-dir=tmp | |
--ignore-dir=brakeman | |
--ignore-dir=.idea |
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 ScopeOperators | |
def or(other). | |
left = arel.constraints.reduce(:and) | |
right = other.arel.constraints.reduce(:and) | |
scope = merge(other) | |
left ||= Arel::Nodes::Grouping.new(0) # take none if no conditions | |
right ||= Arel::Nodes::Grouping.new(0) # take none if no conditions | |
scope.where_values = [ Arel::Nodes::Grouping.new(left).or(Arel::Nodes::Grouping.new(right)) ] | |
scope | |
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
# to bypass mass-assignment | |
Dir[Rails.root.join('app/models/*')].each {|f| require_dependency f } | |
ActiveRecord::Base.descendants.each {|m| p m.name; m.attr_accessible(*m.attribute_names)} |
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
require 'rubygems' | |
ENV["RAILS_ENV"] ||= 'test' | |
if defined? SimpleCov | |
require 'simplecov' | |
SimpleCov.start 'rails' | |
end | |
require 'rails/application' |
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 Search | |
class AdvancedProfileSearch < ::Search::Search | |
attr_reader :search_object, :search_params | |
def initialize(search_object, search_params) | |
@search_object, @search_params = search_object, search_params | |
end | |
# https://github.com/sunspot/sunspot#readme | |
class << self | |
def perform_without_rescue(search_params) |
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 Search | |
class Search | |
class << self | |
def perform(*args) | |
results = nil | |
with_exception_handling { results = perform_without_rescue(*args) } | |
::Search::SearchResults.new(results) | |
end | |
def perform_without_rescue(search_params, *classes) |
OlderNewer