Skip to content

Instantly share code, notes, and snippets.

View a-chernykh's full-sized avatar

Andrey Chernykh a-chernykh

View GitHub Profile
@a-chernykh
a-chernykh / application_controller.rb
Created June 22, 2011 19:43
devise force https for sign in and sign up routes
class ApplicationController < ActionController::Base
before_filter :ensure_proper_protocol
protected
def ssl_allowed_action?
(params[:controller] == 'users/sessions' && ['new', 'create'].include?(params[:action])) ||
(params[:controller] == 'users/registrations' && ['new', 'create', 'edit', 'update'].include?(params[:action])) ||
(params[:controller] == 'users/omniauth_callbacks')
end
84091/0x9c28d: 29323312 20 7 mmap(0x0, 0x82000, 0x3, 0x1002, 0x3000000, 0x100000001) = 0x7760000 0
libSystem.B.dylib`__mmap+0xa
libSystem.B.dylib`large_malloc+0x471
libSystem.B.dylib`szone_malloc_should_clear+0xd3e
libSystem.B.dylib`szone_realloc+0x844
libSystem.B.dylib`malloc_zone_realloc+0x5c
libSystem.B.dylib`realloc+0xa9
ruby`ruby_xrealloc+0x86
ruby`str_buf_cat+0xcf
@a-chernykh
a-chernykh / gist:1014249
Created June 8, 2011 11:31
prototype-rails with latest Rails error
[andrey-mbp ~/projects/rails/alt12-site rails3]$ rails s
WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.3
=> Booting Mongrel
=> Rails 3.1.0.rc2 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/akhkharu/.rvm/gems/ruby-1.9.2-head@alt12/gems/actionpack-3.1.0.rc2/lib/action_dispatch/testing/assertions.rb:14:in `<module:Assertions>': uninitialized constant ActionDispatch::Assertions::SelectorAssertions (NameError)
from /Users/akhkharu/.rvm/gems/ruby-1.9.2-head@alt12/gems/actionpack-3.1.0.rc2/lib/action_dispatch/testing/assertions.rb:2:in `<module:ActionDispatch>'
from /Users/akhkharu/.rvm/gems/ruby-1.9.2-head@alt12/gems/actionpack-3.1.0.rc2/lib/action_dispatch/testing/assertions.rb:1:in `<top (required)>'
@a-chernykh
a-chernykh / gist:1006487
Created June 3, 2011 15:08
Error when reconfiguring thinking_sphinx when used with combination with meta_search
[andrey-mbp ~/projects/rails/alt12-site rails3]$ rake ts:config --trace
WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.3
** Invoke ts:config (first_time)
** Invoke thinking_sphinx:configure (first_time)
** Invoke thinking_sphinx:app_env (first_time)
** Execute thinking_sphinx:app_env
** Execute thinking_sphinx:configure
Generating Configuration to /Users/akhkharu/projects/rails/alt12-site/config/development.sphinx.conf
rake aborted!
Association named 'applications_forums' was not found; perhaps you misspelled it?
@a-chernykh
a-chernykh / staging.rb
Created May 9, 2011 07:51
whenever + capistrano - custom log path
# Configure whenever
set :whenever_environment, rails_env
set :whenever_output, '/var/www/apps/alt12/current/log/crontab.log'
set :whenever_update_flags, "--update-crontab #{whenever_identifier} --set environment=#{whenever_environment}\\&output=#{whenever_output}" # notice the escaping \& passed to the shell
@a-chernykh
a-chernykh / cancel_zencoder_jobs.rb
Created April 25, 2011 14:55
Cancel all zencoder jobs
# jobs deletion has been permanently disabled by Zencoder
Zencoder::Job.list.body.map {|j| Zencoder::Job.cancel(j['job']['id'].to_i)}
def mongo=(server)
case server
when String
host, port = server.split(':')
@con = Mongo::Connection.new(host, port)
@db = @con.db('monque')
@mongo = @db.collection('monque')
@workers = @db.collection('workers')
@failures = @db.collection('failures')
@stats = @db.collection('stats')
We couldn’t find that file to show.
IndieAisle::Application.routes.draw do
resource :cart do
member do
put 'add_subscription'
put 'remove_subscription'
get 'leave'
end
end
resource :order
match '/checkout' => 'orders#checkout'
add_subscription_cart PUT /cart/add_subscription(.:format) {:controller=>"carts", :action=>"add_subscription"}
remove_subscription_cart PUT /cart/remove_subscription(.:format) {:controller=>"carts", :action=>"remove_subscription"}
leave_cart GET /cart/leave(.:format) {:controller=>"carts", :action=>"leave"}
cart POST /cart(.:format) {:controller=>"carts", :action=>"create"}
new_cart GET /cart/new(.:format) {:controller=>"carts", :action=>"new"}
edit_cart GET /cart/edit(.:format) {:controller=>"carts", :action=>"edit"}
cart GET /cart(.:format) {:controller=>"carts", :action=>"show"}
cart PUT /cart(.:format)