Skip to content

Instantly share code, notes, and snippets.

View marks's full-sized avatar

Mark Silverberg marks

View GitHub Profile
def queue_status(queue)
if queue == "is"
response = VoIP::Asterisk.manager_interface.send(:send_action, :Queuestatus)[0].headers
stats = Hash.new
stats["Active Calls (waiting for agent)"] = response.values_at("Calls")[0].to_i
stats["% of calls answered within 60 seconds"] = response.values_at("ServicelevelPerf")[0].to_i
stats["Completed Calls (caller spoke with agent)"] = response.values_at("Completed")[0].to_i
stats["Abandoned Calls (caller hung up while waiting)"] = response.values_at("Abandoned")[0].to_i
return stats
end
params = Hash.new
if ARGV.empty?
puts "Please supply some arguments..."
else
ARGV.each do |pair|
arr = pair.split("=")
key = arr[0].gsub(/[-]/, '')
value = arr[1]
if params.has_key? key
require 'rubygems'
require 'sinatra'
require 'appengine-apis/logger'
require 'appengine-apis/datastore'
require 'json'
get '/' do
logger.info "Sinatra in your Google Appengine p0wning your JRuby"
"I AM SINATRA! Doing a ditty for you on Google Appengine with JRuby!"
end
require 'rubygems'
require 'eventmachine'
module DigitCollector
def post_init
puts "-- someone connected to the echo server!"
end
def receive_data data
p ">>>you sent: #{data}"
require "socket"
tcp_socket = TCPSocket.new('thehost', 20000)
active_call = true
options = { :choices => '1,2,3,4,5,6,7,8,9,0' }
while active_call == true do
result = ask 'Please enter a command.', options
if result.value == 0
active_call = false
get '/' do
case request.env['HTTP_ACCEPT']
when 'application/xml'
"<3 REST!"
else
haml :index
end
end
>> @recordings["skramx_1258124568"]["start_time"].to_s
=> "Wednesday"
@marks
marks / VoiceXML.xml
Created January 1, 2010 23:11
Shorten a URL and read it out loud all from within the Tropo cloud. By @skram / [email protected] / marks on github
<?xml version="1.0" encoding="UTF-8"?>
<speak>
visit tiny u r l dot com slash y,a,t,n,r,u,2 to view your image. all letters are lower case. Again, that's tiny u r l dot com slash y,a,t,n,r,u,2
</speak>
</xml>
<grammar xml:lang="en-us" version="1.0" xmlns="http://www.w3.org/2001/06/grammar" root="ROOT">
<rule id="ROOT">
<item repeat="9">
<ruleref uri="#ONE"/>
</item>
</rule>
<rule id="ONE">
<item>
<one-of>
def events()
{'error' => '/error.json', 'hangup' => '/hangup.json'}.each do |event,path|
puts("on :event => #{event}, :next => #{path} ")
end
# on :event => 'error', :next => '/error.json'
# on :event => 'hangup', :next => '/hangup.json'
end