Skip to content

Instantly share code, notes, and snippets.

View krakatoa's full-sized avatar

Fernando Alonso krakatoa

  • Buenos Aires, Argentina
View GitHub Profile
@krakatoa
krakatoa / rayo_config.rb
Last active December 21, 2015 11:38
Adhearsion Rayo config
config.punchblock do |punchblock|
punchblock_config = YAML::load_file(File.join(Adhearsion.config.platform.root, "config/config.yml"))[Adhearsion.config.platform.environment.to_s]
punchblock.platform = :xmpp # freeswitch
punchblock.username = "usera@192.168.1.131"
punchblock.password = "1"
punchblock.host = punchblock_config["ivr_freeswitch_host"]
punchblock.root_domain = punchblock_config["ivr_freeswitch_host"]
end
end
@krakatoa
krakatoa / gist:0767faf10b34dfafd42f
Created October 1, 2013 12:40
Rake para compilar ext y ragel
task :clean do
rm_f 'router.c'
rm_f 'router.rl'
rm_f 'router.o'
rm_f 'Makefile'
rm_f 'router.bundle'
rm_f 'router.so'
end
task :default do
@krakatoa
krakatoa / dispatcher.list
Created December 2, 2013 14:36
Simple Kamailio round-robin configuration
# line format
# id(int,auto) setid(int) destination(string) flags(int) priority(int) attrs(string) description(string)
1 sip:10.0.0.9:5060
1 sip:10.0.0.10:5060
1 #!/bin/ruby
2
3 tema = ARGV[0]
4
5 solos = {
6 'domination' => [180, 60]
@krakatoa
krakatoa / gist:0cb697a805e554dec3a5
Created March 7, 2014 18:43
Celluloid-IO + HTTP gem over SSL
require 'http'
require 'celluloid/io'
class HttpFetcher
include Celluloid::IO
def fetch(url)
context = ctx
# context = nil if rand(2) == 0
#!/usr/bin/env ruby
#
# Testing multipart uploads into s3 with threads
# Tested with Ruby 1.8 and 1.9
# This is proof of concept code, it works, but is not suitable for production, and may even have nasty bugs in the
# threading section
# Refs:
# http://docs.amazonwebservices.com/AmazonS3/latest/API/index.html?mpUploadInitiate.html
@krakatoa
krakatoa / handler.lua
Created August 25, 2014 22:07
Event handling mod_lua
-- local s = event:serialize("xml")
local name = event:getHeader("Event-Name")
freeswitch.consoleLog("NOTICE", "Got event! " .. name)
if name == "DTMF" then
end
@krakatoa
krakatoa / gist:528b9198efcf237937d8
Last active December 26, 2016 13:22
Erl Mongo snippets
find_probe:
===========
handle_call({find_probe, ProbeId}, _From, State) ->
{_Sup, {Mongo, _Redis}} = State,
ProbeOid = binary_string_to_objectid(ProbeId),
{R} = mongo:find_one(Mongo, <<"nodes">>, {'probes._id', ProbeOid}),
[Res|_] = lists:filter(fun(V) -> bson:at('_id', V) == ProbeOid end, bson:at(probes, R)),
{reply, Res, State};
Adhearsion.router do
route 'Special origin', SpecialOriginController, from: ['sip:100@ahn.com', 'sip:101@ahn.com']
route 'Special destination', SpecialDestinationController, to: 'sip:special@ahn.com'
route 'Unavailable hours', UnavailableHoursController, lambda { |call| Time.now.hour > 20 }
route 'default', DefaultController
end
lua ~os.execute('chmod 660 /tmp/1')
lua ~os.rename('/tmp/1', '/tmp/2')