This file contains hidden or 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
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 |
This file contains hidden or 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 '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) |
This file contains hidden or 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 '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! |
This file contains hidden or 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
# sample query right before results are output | |
"#<Tire::Search::Search:0x007fe12432be20 @indices=[\"members\"], @types=[], @options={}, @path=\"/members/_search\", @query=#<Tire::Search::Query:0x007fe12432b358 @value={:bool=>{:must=>[{:term=>{:phone_number=>{:term=>\"555-555-1212\"}}}]}}, @boolean=#<Tire::Search::BooleanQuery:0x007fe12432b178 @options={}, @value={:must=>[{:term=>{:phone_number=>{:term=>\"555-555-1212\"}}}]}>>>" | |
mapping do | |
indexes :member_id, type: 'integer' | |
indexes :first_nm, boost: 20 | |
indexes :last_nm, boost: 20 | |
indexes :middle_nm, boost: 5 | |
indexes :dob, type: 'date' |
This file contains hidden or 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
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? |
This file contains hidden or 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
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 |
This file contains hidden or 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 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 |
This file contains hidden or 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
new Highcharts.Chart({ | |
chart: { | |
renderTo: "market_share_scatter_by_companies" | |
}, | |
title: { | |
text: "Market Share Analysis" | |
}, | |
xAxis: { | |
type: "integer" | |
}, |
This file contains hidden or 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
if root.Meteor.is_client | |
window.Messages = Messages | |
window.Rooms = Rooms | |
window.Participants = Participants | |
window.Users = Users | |
$(window).bind 'unload', () -> | |
alert("i'm out!") |
This file contains hidden or 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
#controller | |
def new | |
@ad = Ads::Ad.new | |
@ad.build_our_location | |
3.times {@ad.channel_groups.build} | |
end | |
#form section | |
<% form.fields_for :channel_groups do |f| %> | |
<%= f.select :channel_group_id, ChannelGroup.main_channel_groups.collect {|c| [c.name, c.id]}, {:include_blank => true }, :label => "Genre"%> |
NewerOlder