Skip to content

Instantly share code, notes, and snippets.

@jonpaul
jonpaul / public_controller.rb
Created October 28, 2011 18:25 — forked from bsodmike/public_controller.rb
Render 404 via catch-all route in Rails 3.1
class CmsPageNotFound < StandardError; end
class PublicController < ApplicationController
rescue_from CmsPageNotFound do
render 'not_found', :status => :not_found and return false
end
def index
end
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
default_run_options[:pty] = true
set :rvm_ruby_string, '1.9.2-p290' # Or whatever env you want it to run in.
set :application, "masterdatamachine"
set :domain, '50.57.132.151'
set :applicationdir, "/var/www/#{application}"
set :repository, "[email protected]:glideint/Master-Data-Machine.git"
@jonpaul
jonpaul / Capistrano-Deployment-Recipe.rb
Created October 19, 2011 13:22 — forked from mrrooijen/Capistrano-Deployment-Recipe.rb
a "base" Capistrano Rails Deployment Recipe. Use it to deploy your Rails application. It is also easily expandable. So feel free to grab this Recipe and add your own tasks/customization!
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
<div id='container' style="width:960px;position:relative;margin:0 auto;">
<nav style="background:url('nav_bg.png') no-repeat;position:relative;left:-330px;width:1620px;height:377px;"/>
<div class="navContainer" style="width:960px;margin:0 auto;">
<ul>
<li>SOME CONTENT</li>
<li>SOME CONTENT</li>
<li>SOME CONTENT</li>
</ul>
</div>
</nav>
orgs_array.each do |uid|
search_results[uid] = Listing.search do
query {
boolean do
should { term :short_description, search_terms}
should { term :full_description, search_terms}
should { term :manufacturers_name, search_terms}
should { term :manufacturers_part_num, search_terms}
should { term :suppliers_name, search_terms}
should { term :suppliers_part_num, search_terms}
@jonpaul
jonpaul / gist:1295538
Created October 18, 2011 14:22
capistrano deploy
** [out :: ...] Your bundle is complete! It was installed into ./vendor/bundle
command finished in 89049ms
triggering after callbacks for `deploy:bundle_gems'
.
.
.
command finished in 681ms
* executing `deploy:migrate'
* executing "cd .../releases/20111018141607 && rake RAILS_ENV=production db:migrate"
servers: [...]
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
default_run_options[:pty] = true
set :rvm_ruby_string, '1.9.2-p290' # Or whatever env you want it to run in.
set :application, "masterdatamachine"
set :domain, '50.57.132.151'
set :applicationdir, "/var/www/#{application}"
set :repository, "[email protected]:glideint/Master-Data-Machine.git"
@jonpaul
jonpaul / error
Created October 17, 2011 00:18
ruby 1.8.7 problem on lion
╭─core@new-host-2 ~/egiden ‹ruby-1.8.7@ryanbigg›
╰─$ rvm gem update --system
WARN: Please note that `rvm gem ...` is only an alias to `rvm do gem ...`,
it might work different as in earlier versions of RVM and will be shortly removed!
/Users/core/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/timeout.rb:60: [BUG] Bus Error
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]
/Users/core/.rvm/scripts/set: line 51: 66284 Abort trap: 6 gem update '--system'
Updating rubygems-update
Fetching: rubygems-update-1.8.11.gem (100%)
@jonpaul
jonpaul / some_hash
Created October 14, 2011 19:23
Accessing values from this object inside my hash?
ruby-1.9.2-p290 :048 > @listings[1]
=> #<Tire::Results::Collection:0x00000103385a00 @response={"took"=>6, "timed_out"=>false, "_shards"=>{"total"=>5, "successful"=>5, "failed"=>0}, "hits"=>{"total"=>29, "max_score"=>0.021450784, "hits"=>[{"_index"=>"mongo-listings", "_type"=>"listing", "_id"=>"4e95fc502b36da04a3000012", "_score"=>0.021450784, "_source"=>{"_id"=>"4e95fc502b36da04a3000012", "action"=>nil, "air_connection"=>nil, "base_unit_of_measure"=>"EA", "country_of_origin"=>"US", "diaphragm_area"=>nil, "diaphragm_case_material"=>nil, "diaphragm_material"=>nil, "full_description"=>"ACTUATOR VALVE DIAPHRAGM; 65 PSI SPRING,SIZE 60,2 IN STEM TRV,FISHER CONTROLS CO MODEL 667-151M, AS SUPPLIED ON PO PN-R81-34-0081-NA", "klass_attributes"=>"ACTUATOR:VLVDPHR", "listing_name"=>"Some funky import", "manufacturers_name"=>"FISHER CONTROLS INTERNATIONAL", "manufacturers_part_num"=>"667-60-151M", "maximum_stem_travel"=>"2 IN", "minimum_order_qty"=>"0", "mounting"=>nil, "organization_id"=>1, "product_type"=>"Service", "s
@jonpaul
jonpaul / data.json
Created October 13, 2011 21:12
data from query hit
{"_index"=>"mongo-listings",
"_type"=>"listing",
"_id"=>"4e95fc502b36da04a3000012",
"_score"=>0.07227325,
"_source"=>
{"_id"=>"4e95fc502b36da04a3000012",
"action"=>nil,
"air_connection"=>nil,
"base_unit_of_measure"=>"EA",
"country_of_origin"=>"US",