Skip to content

Instantly share code, notes, and snippets.

@rbeene
rbeene / order.rb
Created August 16, 2014 23:49 — forked from pcreux/order.rb
ActiveAdmin.register Order do
# Export the current collection of items with filtering and sorting
# List the current collection ids
collection_action :export_txt do
render :text => collection.map { |order| order.id }.join(', ')
end
# Add a button to index page to export current collection as txt
require 'factory_girl_rails'
require 'rspec'
require 'rspec-rails'
require 'rspec/mocks/standalone' # => if factories need stubs (for remote services for example)
include FactoryGirl::Syntax::Methods # make FG methods available at top level, so you can do `> create :user`
def reload_factories!
FactoryGirl.instance_variable_set(:@factories, nil) # => clear loaded factories/sequences
# FactoryGirl.instance_variable_set(:@sequences, nil)
@rbeene
rbeene / Guardfile
Created March 26, 2013 14:42 — forked from thbar/Guardfile
require 'childprocess'
guard 'shell' do
watch %r{^app/(.+)\.rb$} do |m|
`killall rake`
# Why this:
# - spawn a child process to avoid locking Guard
# - make sure that the child process has stdout and stdin otherwise it crashes
# - bonus point: get REPL access in the simulator!
REMOVE_WORDS_ARRAY = ["llc", "co", "corp", "inc"]
businesses_array = [["the bakery", "10012"],["law office inc", "10014"]]
businesses_hashes = []
businesses_array.each do |business|
our_hash = {}
our_hash['BusinessName'] = business[0].strip unless business[0].nil?
our_hash['BusinessZipCode'] = business[1].strip unless business[1].nil?
@rbeene
rbeene / es.sh
Created September 28, 2012 19:09 — forked from rajraj/es.sh
Install ElasticSearch on CentOS 6
cd ~
sudo yum update
sudo yum install java-1.7.0-openjdk.i686 -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.9.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
class ActiveRecord::Base
def self.inherited(klass)
callbacks = [:before_validation, :before_save, :before_create, :before_update]
callbacks.each do |callback|
klass.send(callback) do
return unless respond_to?(:updated_by) || updated_by.nil?
self.updated_by = Thread.current[:current_user]
end
end