Skip to content

Instantly share code, notes, and snippets.

View jmoren's full-sized avatar

Jorge jmoren

  • Buenos Aires - Argentina
View GitHub Profile
@jmoren
jmoren / users_controller.rb
Created August 24, 2012 18:04
Testing login from cookies
def index
unless cookies[:auth_token].nil?
@user = User.find_by_remember_token(cookies[:auth_token])
cookies[:auth_token] = { :domain => "localhost",
:value => @user.remember_token ,
:expires => @user.remember_token_expires_at
}
@users = User.find(:all, :order=>'user_group_id')
ps ax | grep ruby
1788 ? Ss 0:00 SCREEN -d -m -S pingpong ruby stompcat.rb
1825 pts/2 Ss+ 0:00 ruby stompcat.rb
2786 ? Ss 0:00 SCREEN -d -m -S pingpong ruby stompcat.rb
2791 pts/4 Ss+ 0:00 ruby stompcat.rb
2853 pts/3 S+ 0:00 grep ruby
ps ax | grep active
1828 ? Sl 0:01 /home/vagrant/apache-activemq-5.3.2/bin/linux-x86-64/wrapper /home/vagrant/apache-activemq-5.3.2/bin/linux-x86-64/wrapper.conf wrapper.syslog.ident=ActiveMQ wrapper.pidfile=/home/vagrant/apache-activemq-5.3.2/bin/linux-x86-64/./ActiveMQ.pid wrapper.daemonize=TRUE
@jmoren
jmoren / error log
Created September 18, 2012 14:13
Error rspec
DB = Sequel.connect("mysql://root@localhost/fdialer_production") if ENV['RACK_ENV'] == 'production'
DB = Sequel.mysql("fdialer_testing", :user => "root", :host => "localhost") if ENV['RACK_ENV'] == 'testing'
$> rspec rspec/reports_spec.rb
/home/jmoren/.rvm/gems/ruby-1.9.3-p194/gems/sequel-3.39.0/lib/sequel/model/base.rb:224:in `db': No database associated with Sequel::Model: have you called Sequel.connect or Sequel::Model.db= ? (Sequel::Error)
from /home/jmoren/.rvm/gems/ruby-1.9.3-p194/gems/sequel-3.39.0/lib/sequel/model/base.rb:356:in `inherited'
from /home/jmoren/.rvm/gems/ruby-1.9.3-p194/gems/sequel-3.39.0/lib/sequel/model/associations.rb:979:in `inherited'
from /home/jmoren/deviget/hello_hunter/betterwrx-reports/models/user.rb:1:in `<top (required)>'
@jmoren
jmoren / gist:3756952
Created September 20, 2012 16:35
error tests
def query_calls
query = Call.where(:user_id => @agent.id)
query = query.where {created_at >= "#{@start_date}"} unless @start_date.nil?
query = query.where {created_at <= "#{@end_date}" } unless @end_date.nil?
$logger.info "Start: #{@start_date}" unless @start_date.nil?
$logger.info "End: #{@end_date}" unless @end_date.nil?
$logger.warn "Query: #{query.inspect}"
return query
end
require "./models/agent"
require "./models/call"
class AgentStat
attr_accessor :start_date, :end_date, :campaigns, :agent
def initialize(agent, *args)
@agent = agent
@campaigns ||= []
end
@jmoren
jmoren / named_list_stat.rb
Created October 29, 2012 14:24
logs query
def logs_query
query = Log.join_table(:inner, Contact, :contact_id => :contact_id)
query = query.join_table(:inner, NamedList.where(:id => @named_list.id), :id => :qcall_contact_list_id)
query = query.where {|log| log.created_at >= @start_date}.qualify(:logs) if @start_date
query = query.where {|log| log.created_at <= @end_date}.qualify(:logs) if @end_date
query = query.where(Sequel.like(:text, *dispo_statuses_for_like)).qualify(:logs)
query = query.group_and_count(:text)
query
end
DATA: [{"_id"=>BSON::ObjectId('50f7e2d5f9e0c64dfbd505d0'), "stats"=>{"140"=>{"tc"=>73, "tt"=>3795, "tta"=>51.9863, "cph"=>69.52}}, "user_id"=>74},
{"_id"=>BSON::ObjectId('50f7e2d9f9e0c64dfbd50652'), "stats"=>{"140"=>{"tc"=>135, "tt"=>4551, "tta"=>33.7111, "cph"=>108.0}}, "user_id"=>74},
{"_id"=>BSON::ObjectId('50f7e2d9f9e0c64dfbd5065a'), "stats"=>{"140"=>{"tc"=>11, "tt"=>267, "tta"=>24.2727, "cph"=>165.0}}, "user_id"=>74},
{"_id"=>BSON::ObjectId('50f7e2d9f9e0c64dfbd50661'), "stats"=>{"140"=>{"tc"=>60, "tt"=>1585, "tta"=>26.4167, "cph"=>138.46}, "81"=>{"tc"=>5, "tt"=>80, "tta"=>16.0, "cph"=>300.0}}, "user_id"=>74},
{"_id"=>BSON::ObjectId('50f7e2d9f9e0c64dfbd50666'), "stats"=>{"81"=>{"tc"=>1, "tt"=>8, "tta"=>8.0, "cph"=>0.0}}, "user_id"=>74},
{"_id"=>BSON::ObjectId('50f7e2d9f9e0c64dfbd5066f'), "stats"=>{"81"=>{"tc"=>42, "tt"=>3184, "tta"=>75.8095, "cph"=>47.55}}, "user_id"=>74},
{"_id"=>BSON::ObjectId('50f7e2d5f9e0c64dfbd505d5'), "stats"=>{"81"=>{"tc"=>183, "tt"=>6796, "tta"=>37.1366, "cph"=>97.17}}, "user
@jmoren
jmoren / gist:6584541
Created September 16, 2013 18:28
AHN log ultima prueba (Id: 3) Sonido dial 1 (para ir a un recording container) Beep End
Starting Adhearsion server at /vagrant
/vagrant/config/adhearsion.rb:8: warning: already initialized constant RECORDING_BASE_PATH
[2013-09-16 15:30:15] INFO Adhearsion::Initializer: Setting RAILS_ENV to "development"
[2013-09-16 15:30:15] WARN AhnRiemann::Plugin: Ahn-Riemann client connected to localhost:5555
[2013-09-16 15:30:15] INFO RepositoriesPlugin: Initializing ActiveRecord
[2013-09-16 15:30:15] INFO Adhearsion::PunchblockPlugin::Initializer: Starting connection to server
[2013-09-16 15:30:15] DEBUG Punchblock::Connection::Freeswitch: Starting the RubyFS stream
[2013-09-16 15:30:15] DEBUG RubyFS::Stream: Starting up...
[2013-09-16 15:30:16] INFO Adhearsion::PunchblockPlugin::Initializer: Connected to Punchblock server
[2013-09-16 15:30:16] INFO Adhearsion::Process: Transitioning from booting to running with 0 active calls due to booted event.
@jmoren
jmoren / gist:6584684
Created September 16, 2013 18:40
Freeswitch log
2013-09-16 15:14:41.286811 [INFO] mod_dialplan_xml.c:558 Processing 1000 <1000>->3 in context default
Dialplan: sofia/internal/1000@192.168.33.10 parsing [default->unloop] continue=false
Dialplan: sofia/internal/1000@192.168.33.10 Regex (PASS) [unloop] ${unroll_loops}(true) =~ /^true$/ break=on-false
Dialplan: sofia/internal/1000@192.168.33.10 Regex (FAIL) [unloop] ${sip_looped_call}() =~ /^true$/ break=on-false
Dialplan: sofia/internal/1000@192.168.33.10 parsing [default->tod_example] continue=true
Dialplan: sofia/internal/1000@192.168.33.10 Date/Time Match (PASS) [tod_example] break=on-false
Dialplan: sofia/internal/1000@192.168.33.10 Action set(open=true)
Dialplan: sofia/internal/1000@192.168.33.10 parsing [default->holiday_example] continue=true
Dialplan: sofia/internal/1000@192.168.33.10 Date/TimeMatch (FAIL) [holiday_example] break=on-false
Dialplan: sofia/internal/1000@192.168.33.10 parsing [default->global-intercept] continue=false
@jmoren
jmoren / gist:6811827
Created October 3, 2013 15:33
log de dos llamadas
2013-10-03 12:35:15.328912 [NOTICE] switch_channel.c:1030 New Channel sofia/internal/sipp@192.168.33.1 [66619780-2c41-11e3-a0c8-f3690e1362c8]
2013-10-03 12:35:15.328912 [DEBUG] switch_core_session.c:999 Send signal sofia/internal/sipp@192.168.33.1 [BREAK]
2013-10-03 12:35:15.328912 [DEBUG] switch_core_session.c:999 Send signal sofia/internal/sipp@192.168.33.1 [BREAK]
2013-10-03 12:35:15.328912 [DEBUG] switch_core_session.c:999 Send signal sofia/internal/sipp@192.168.33.1 [BREAK]
2013-10-03 12:35:15.328912 [DEBUG] switch_core_session.c:999 Send signal sofia/internal/sipp@192.168.33.1 [BREAK]
2013-10-03 12:35:15.328912 [DEBUG] switch_core_session.c:999 Send signal sofia/internal/sipp@192.168.33.1 [BREAK]
2013-10-03 12:35:15.328912 [DEBUG] switch_core_state_machine.c:415 (sofia/internal/sipp@192.168.33.1) Running State Change CS_NEW
2013-10-03 12:35:15.328912 [DEBUG] switch_core_state_machine.c:433 (sofia/internal/sipp@192.168.33.1) State NEW
2013-10-03 12:35:15.348887 [DEBUG] sofia.c:7873 IP 192.168.33.1 Reject