Skip to content

Instantly share code, notes, and snippets.

View andrius's full-sized avatar

Andrius Kairiukstis andrius

View GitHub Profile
@andrius
andrius / ruby-agi-daemon.rb
Created February 25, 2013 10:02
How to daemonise Ruby AGI app.
#!/usr/bin/env ruby
# NOTE - Following code was tested with AsteriskRuby gem and Adhearsion v. 1.2.3
require 'rubygems'
require 'pp'
require 'monitor'
require 'timeout'
require 'time'
require 'AGIServer'
@andrius
andrius / business-times.rb
Created February 22, 2013 22:34
Business time management for Ruby application Say, application need to manage time flexible, what do you think about this implementation?
# Migration
create_table :business_time_members do |t|
t.string :name, :limit => 100
t.integer :business_time_id
t.time :time_from, :default => '2000-01-01 00:00:00'
t.time :time_to, :default => '2000-01-01 23:59:59'
t.integer :weekday # 0 - sunday, 1 - monday, 2 -tuesday, ...
t.integer :day_of_month # 1-31
t.integer :month # 1-12
@andrius
andrius / gist:4984463
Created February 19, 2013 09:45
Old AGI sample of manipulaiton with dynamic agents for asterisk 1.2 and 1.4
#!/usr/bin/ruby
require 'rubygems'
require 'rastman'
require 'AGIServer'
require 'AGISelection'
require 'AGIMenu'
AMI = Rastman::Manager.new(@@config[:manager][:user],
@@config[:manager][:secret],
@andrius
andrius / VoIP-questionnaire.rb
Last active December 12, 2015 12:39
Questionnaire application, includes database and Asterisk AGI (from line 100). For new caller, app request to enter an PIN code to authenticate. App monitors how many times caller was returned to the system and how many attempts did to answer question.
#!/bin/env ruby
# This application was made and tested in production with Ruby 1.8x
require 'rubygems'
require 'mysql'
require 'active_record'
require 'AGIServer'
require 'AGIMenu'
require 'AGISelection'