cat /proc/sys/net/core/somaxconn
Will show you how many connections you can have. This should be 1024, because Phusion Passenger is hard coded for this value. Mine was 128!
Do this:
sudo sysctl -w net.core.somaxconn=1024
And then restart nginx.
cat /proc/sys/net/core/somaxconn
sudo sysctl -w net.core.somaxconn=1024
perl -MCPAN -e shell
install Bundle::CPAN
install Digest::SHA1
install Compress::Zlib
chmod +x rtmpdump
sudo cp rtmpdump /usr/local/bin/.
./get_flash_videos http://www.itv.com/itvplayer/video/?Filter=228293
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
watch = [
"/Users/smyp/development/wl/xtf/horse",
"/Users/smyp/development/wl/xtf/sport",
"/Users/smyp/development/wl/xtf/live",
"/Users/smyp/development/wl/xtf/alpha"
]
if ENV['RAILS_ENV'] == 'production'
watch = ["/home/mcdata/horse", "/home/mcdata/sport", "/home/mcdata/live", "/home/mcdata/alpha"]
end
dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
daemon_options = {
:app_name => "xturf_file_monitor",
:multiple => false,
:dir_mode => :normal,
:dir => File.join(dir, 'tmp', 'pids'),
:backtrace => true
}
class PriceDaemon
attr_accessor :base_dir
def initialize(base_dir)
self.base_dir = base_dir
end
def dostuff
logger.info "About to start job for #{base_dir}"
EventMachine::run {
# Your code here
xhj = PriceFileJob.new(base_dir)
xhj.clear_backlog
FSSM.monitor(base_dir) do
create {|base, relative| xhj.clear_backlog}
update {|base, relative| xhj.clear_backlog}
end
}
end
def logger
@@logger ||= ActiveSupport::BufferedLogger.new("#{RAILS_ROOT}/log/price_file_monitor.log")
end
end
watch.each_with_index do |base_dir, i|
Daemons.run_proc("price_daemon_#{i}", daemon_options) do
Dir.chdir dir
PriceDaemon.new(base_dir).dostuff
end
end
class PriceFileJob
attr_accessor :base_dir
def initialize(base_dir)
self.base_dir = base_dir
logger.info "watching #{base_dir}"
end
def logger
@@logger ||= Logger.new("#{RAILS_ROOT}/log/price_file_job_#{base_dir.split("/").last}.log", "daily")
end
def clear_backlog
files = Dir.new(base_dir).entries.sort_by{|c| File.stat(File.join(base_dir, c)).ctime}
files.each do |file|
process_file(file)
end
end
def process_file(file)
end
private
end
before "mc:release", "file_processors:stop"
after "mc:release", "file_processors:start"
namespace :file_processors do
desc "start processors"
task :start, :roles => :db do
run "cd #{current_path}; RAILS_ENV=#{fetch :rails_env} ruby ./script/price_file_monitor.rb start"
end
desc "get status of processors"
task :status, :roles => :db do
run "cd #{current_path}; RAILS_ENV=#{fetch :rails_env} ruby ./script/price_file_monitor.rb status"
end
desc "stop processors"
task :stop, :roles => :db do
run "cd #{current_path}; RAILS_ENV=#{fetch :rails_env} ruby ./script/price_file_monitor.rb stop"
end
end
<div id="queue"><%= render :partial => 'queue' %></div>
<script>
$(document).ready(function() {
$('.pagination a').attr('data-remote', 'true');
});</script>
def show
@user = User.find(params[:id])
@queue_items = @user.queue_items.with_state(:pending).paginate(:page => params[:queue_page] || 1, :per_page => 1)
respond_to do |format|
format.html
format.js
end
end
$('#queue').html('<%=escape_javascript render :partial => "queue" %>');
$('.pagination a').attr('data-remote', 'true');
rails g controller subscriptions new
create app/controllers/subscriptions_controller.rb
route get "subscriptions/new"
invoke erb
create app/views/subscriptions
create app/views/subscriptions/new.html.erb
invoke rspec
create spec/controllers/subscriptions_controller_spec.rb
create spec/views/subscriptions
create spec/views/subscriptions/new.html.erb_spec.rb
invoke helper
create app/helpers/subscriptions_helper.rb
invoke rspec
create spec/helpers/subscriptions_helper_spec.rb
class SubscriptionsController < Devise::RegistrationsController
def new
@subscription_plans = SubscriptionPlan.visible
end
end
<% title "Sign up" %>
<div>Pick a subscription</div>
<% semantic_form_for :subscription, :url => users_sign_up2_path, :html => { :method => :get } do |form| %>
<%= form.input :plan_id, :as => :radio, :collection => @subscription_plans.map{|sp| ["#{sp.description}", sp.id]} %>
<% form.buttons do %>
<%= form.commit_button "Continue" %>
<% end %>
<% end %>
devise_for :users do
get "/users/sign_up" => "subscriptions#new"
get "/users/sign_up2" => "registrations#new"
end
class RegistrationsController < Devise::RegistrationsController
def new
@address = Address.new
begin
@subscription_plan = SubscriptionPlan.find(params[:subscription][:plan_id])
rescue Exception => e
redirect_to users_sign_up_path and return
end
@user = User.new
end
protected
# Build a devise resource passing in the session. Useful to move
# temporary session data to the newly created user.
def build_resource(hash=nil)
address_info = params[:user].delete(:address) rescue {}
begin
sub_info = params[:user].delete(:subscription_plan)
@subscription_plan = SubscriptionPlan.find sub_info["id"]
rescue Exception => e
redirect_to users_sign_up_path and return
end
subscription = Subscription.new(:subscription_plan_id => @subscription_plan.id)
@address = Address.new(address_info.merge(:country => "US"))
@user = User.new(params[:user].merge(:first_name => @address.first_name, :last_name => @address.last_name))
@user.subscription = subscription
@user.current_shipping_address = @address
end
def after_sign_up_path_for(resource)
new_user_billing_detail_path(resource)
end
end
context "iridium" do
before do
BillingDetail.gateway =
ActiveMerchant::Billing::IridiumGateway.new(
:login => "Casdasdasd",
:password => "asdasdasd",
:enable_3d_secure => true)
end
it "should work" do
bd = Factory.build(:unsaved_billing_detail)
bd.should_receive(:ready!)
credit_card = Factory.build(:iridium_good_no_3ds)
address = Factory.build(:iridium_good_no_3ds_address)
bd.address = address
bd.authorize(100, credit_card)
end
it "should fail" do
bd = Factory.build(:unsaved_billing_detail)
bd.should_receive(:fail!)
credit_card = Factory.build(:iridium_card_declined)
address = Factory.build(:iridium_card_declined_address)
bd.address = address
lambda {
bd.authorize(100, credit_card)
}.should raise_error(TGR::GatewayError)
end
end
Factory.define :iridium_good_no_3ds, :class => ActiveMerchant::Billing::CreditCard do |cc|
cc.number "4976000000003436"
cc.last_name "Watson"
cc.first_name "John"
cc.verification_value "452"
cc.month "12"
cc.year "2012"
end
Factory.define :iridium_good_no_3ds_address, :class => Address do |address|
address.last_name "Watson"
address.first_name "John"
address.address_1 "32 Edward Street"
address.city "Camborne"
address.state "Cornwall"
address.zipcode "TR14 8PA"
address.country "GB"
end
Factory.define :iridium_card_declined, :class => ActiveMerchant::Billing::CreditCard do |cc|
cc.number "4921810000009076"
cc.last_name "Lewis"
cc.first_name "Jack"
cc.verification_value "875"
cc.month "12"
cc.year "2012"
end
Factory.define :iridium_card_declined_address, :class => Address do |address|
address.last_name "Lewis"
address.first_name "Jack"
address.address_1 "4 Wing Road"
address.city "Leighton Buzzard"
address.state "Bedfordshire"
address.zipcode "LU7 0JB"
address.country "GB"
end