Skip to content

Instantly share code, notes, and snippets.

View andrius's full-sized avatar

Andrius Kairiukstis andrius

View GitHub Profile
# Start Adhearsion in JRuby, while building a pidfile as soon as possible.
def ahnctl_start
shell_command = "#{exec_ahn_async} && #{wait} && #{save_pid}"
%x{shell_command}
end
private
# Run start in the background, since it is not daemonized.
@andrius
andrius / sip.conf
Last active August 29, 2015 14:04
Asterisk PBX SIP.conf, which works :)
[general]
udpbindaddr=0.0.0.0:5060
tcpenable=yes
tcpbindaddr=0.0.0.0:5060
tlsenable=yes
tlsbinddir=0.0.0.0:5060
;tlsverify=no
@andrius
andrius / install-asterisk-debian.sh
Created August 2, 2014 10:05
Install script for Asterisk PBX on debian
apt-get --yes install curl wget rsync subversion git-core \
build-essential automake autoconf libtool bison libssl-dev openssl libncurses-dev libnewt-dev \
libreadline6 libreadline-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev \
libxslt-dev libc6-dev libcurl4-openssl-dev libgdbm-dev libffi-dev sudo \
libsqlite3-dev sqlite3 libtiff-dev ghostscript usbutils libusb-dev unzip autoconf automake \
minicom mc vim screen tmux libncurses5-dev libxml2-dev libssl-dev uuid-dev \
libpcap-dev ngrep libpcre++-dev libpcre3-dev wpasupplicant w3m ssl-cert ca-certificates \
ffmpeg espeak libespeak-dev libsndfile1-dev libsamplerate0-dev libsrtp0-dev libsrtp0 \
uuid-dev uuid
@andrius
andrius / 1-google-tts-usage.rb
Last active August 29, 2015 14:05
Google TTS
def tts(message, lang = 'en-US')
GoogleTTS.download(message, lang)
end
def read_pin(message, lang = 'en-US')
prompt = { audio: ANNOUNCEMENTS[lang][message],
max_digits: 10,
timeout: 20 }
#3.times do |attempt_no|
data = begin
module Configuration
Error = Class.new StandardError
class << self
def config(&block)
@config ||= initialize_config
block_given? and yield @config
@config
end
class CreateUsers
end
Sequel.migration do
change do
create_table :users do
primary_key :id
String :email
String :encrypted_password
@andrius
andrius / blogger-to-jekyll.rb
Created October 5, 2014 08:04
Import blogger.com to the jekyll
ruby -rubygems -e 'require "jekyll-import";
JekyllImport::Importers::Blogger.run({
"source" => "/Users/ak/Desktop/blog-10-02-2014.xml",
"no-blogger-info" => false, # not to leave blogger-URL info (id and old URL) in the front matter
"replace-internal-link" => false, # replace internal links using the post_url liquid tag.
})'
@andrius
andrius / fix-permissions.sh
Created September 30, 2015 12:15
Fixes file permissions in Dropbox folder (windows make them wrong)
#!/bin/sh
cd ~/Dropbox
# Remove conflicted copies
find . -iname '*conflicted copy*' | \
awk -F '-8-8-8-8-8-' '{print "\""$1"\""}' | xargs rm -rf
find . -type f \
-perm 755 \
@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'
@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],