Using TTS to read a text file with Asterisk
exten => 3200,1,ReadFile(test=/tmp/test.txt,130) exten => 3200,n,Festival(${test}) exten => 3200,n,Hangup
12388 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
James Robertson http://www.r0bertson.co.uk
exten => 3200,1,ReadFile(test=/tmp/test.txt,130) exten => 3200,n,Festival(${test}) exten => 3200,n,Hangup
detail exten => 3250,1,Answer() exten => 3250,n,Festival('hello world') exten => 3250,n,Hangup
rfcomm connect 0 00:12:D1:E6:57:BE
hcitool rssi 00:12:D1:E6:57:BE
#!/usr/bin/ruby #file : hello-world.rb file = File.new('/etc/asterisk/ruby/output.txt','w') file.puts 'hello world!' file.close
exten => 3000,1,Playback(hello-world) exten => 3000,n,System(/etc/asterisk/ruby/./hello-world.rb) exten => 3000,n,Hangup
hello world!
Channel: SIP/line1 MaxRetries: 2 RetryTime: 60 WaitTime: 30 Context: my-phones Extension: 10
[general] debug=yes ;;Turn on debugging by default. autoprune=no ;;Auto remove users from buddy list. autoregister=yes ;;Auto register users from buddy list. [asterisk] ;;label type=client ;;Client or Component connection serverhost=jamesrobertson.eu ;; talk.google.com username=asterisk@jamesrobertson.eu/Home ;;Username with optional roster. secret=XXXXXXXX ;;Password port=5222 ;;Port to use defaults to 5222 usetls=no ;;Use tls or not ;usesasl=yes ;;Use sasl or not buddy=james@jamesrobertson.eu statusmessage="I am available" ;;Have custom status message for ;;Asterisk. timeout=100 ;;Timeout on the message stack.
exten => 10,1,JABBERSend(asterisk,james@jamesrobertson.eu, Call from ${CALLERID(name)} at number <${CALLERID(num)}> on ${STRFTIME(,GMT-1,%A %B %d %G at %l:%M:%S %p)} ) exten => 10,n,Macro(stdexten,100,100)
def map_pattr(node, fieldx, valuex) begin parameter = node.root.elements["parameter[@field='#{fieldx}']"] parameter.add_attribute('value', valuex) parameter rescue puts 'feedpopulated.rb: map_attr() the field ' + fieldx + ' was not found in params.' raise end end
./feedpopulated.rb:27:in `map_pattr': undefined method `add_attribute' for nil:NilClass (NoMethodError) from ./feedpopulated.rb:51:in `create_record' from ./feedpopulated.rb:49:in `each' from ./feedpopulated.rb:49:in `create_record' from ./recordx.rb:91:in `call_create' from ./s3fileuploader_handler.rb:14:in `call' from ./s3fileuploader_handler.rb:40:in `invoke' from ./uploadtwitteraudio.rb:22:in `initialize' from /usr/lib/ruby/1.8/rexml/element.rb:890:in `each' from /usr/lib/ruby/1.8/rexml/xpath.rb:53:in `each' from /usr/lib/ruby/1.8/rexml/element.rb:890:in `each' from ./uploadtwitteraudio.rb:18:in `initialize' from ./uploadtwitteraudio.rb:72:in `new' from ./uploadtwitteraudio.rb:72
/bookstore/book[1] # Selects the first book element that is the child of the bookstore element. # Note: IE5 and later has implemented that [0] should be the first node, # but according to the W3C standard it should have been [1]!! /bookstore/book[last()] # Selects the last book element that is the child of the bookstore element /bookstore/book[last()-1] # Selects the last but one book element that is the child of the bookstore element /bookstore/book[position()<3] # Selects the first two book elements that are children of the bookstore element //title[@lang] # Selects all the title elements that have an attribute named lang
/bookstore/* # Selects all the child nodes of the bookstore element //* # Selects all elements in the document //title[@*] # Selects all title elements which have any attribute
//book/title | //book/price # Selects all the title AND price elements of all book elements
require 'rubygems' require 'aws/s3' AWS::S3::Base.establish_connection!( :access_key_id => 'REPLACE_ME', :secret_access_key => 'REPLACE_ME' )
AWS::S3::Service.buckets
AWS::S3::Service.buckets.each {|b| puts b.name}
AWS::S3::Bucket.create('t3000')
AWS::S3::Bucket.create('t3000')
AWS::S3::Service.buckets
t3000 = AWS::S3::Bucket.find('t3000')
file = "works.txt"
AWS::S3::S3Object.store(file, open(file), 't3000', :access => :public_read)
#!/usr/bin/env ruby #file : rubys3file2upload.rb require 'rubygems' require 'aws/s3' require 'rexml/document' include REXML class S3FileUpload def initialize(xml_accounts_file, xml_upload_file) initialize_account(xml_accounts_file) main(xml_upload_file) end def initialize_account(accounts_file) file = File.new(accounts_file) doc = Document.new(file) account = doc.root.elements['records/access'] h = Hash.new h[:access_key_id] = account.elements['key_id'].text.to_s h[:secret_access_key] = account.elements['secret'].text.to_s AWS::S3::Base.establish_connection!(h) end def main(xml_upload_file) file = File.new(xml_upload_file) doc = Document.new(file) puts doc doc.root.elements.each('records/file') do |f| local_file = f.elements['local'].text.to_s bucket = f.elements['bucket'].text.to_s mime_type = f.elements['mime_type'].text.to_s upload(local_file, mime_type, bucket) end end def upload(local_file, mime_type, bucket) base_name = File.basename(local_file) puts "Uploading #{local_file} as '#{base_name}' to '#{bucket}'" AWS::S3::S3Object.store( base_name, File.open(local_file), bucket, :content_type => mime_type, :access => :public_read ) puts "Uploaded!" end end if __FILE__ == $0 s3fu = S3FileUpload.new('s3accounts.xml', 's3files2upload.xml') end
<s3accounts> <summary/> <records> <access id="100"><name>REPLACE_ME</name><key_id>REPLACE_ME</key_id><secret>REPLACE_ME</secret></access> </records> </s3accounts>
<s3files2upload> <summary/> <records> <file> <local>autocomplete.html</local> <bucket>t2000</bucket> <mime_type>text/html</mime_type> </file> <file> <local>autocomplete2.html</local> <bucket>t2000</bucket> <mime_type>text/html</mime_type> </file> <file> <local>autocomplete3.html</local> <bucket>t2000</bucket> <mime_type>text/html</mime_type> </file> </records> </s3files2upload>