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 / gist:de4378d050238e8d90bd
Created January 13, 2016 20:33
Grep sneakers deadlocks
cat sneakers.log.1 | grep deadlock | grep -o ".* p-10831" > deadlocks.log
fn a() {
let name = b();
println!("Here the output is '()' Why? {:?}", name);
}
fn b() {
let reader = env.get_reader().unwrap();
let db = reader.bind(&db_handle);
let name = db.get::<&str>(&"Some-Key");
lua ~os.execute('chmod 660 /tmp/1')
lua ~os.rename('/tmp/1', '/tmp/2')
Adhearsion.router do
route 'Special origin', SpecialOriginController, from: ['sip:[email protected]', 'sip:[email protected]']
route 'Special destination', SpecialDestinationController, to: 'sip:[email protected]'
route 'Unavailable hours', UnavailableHoursController, lambda { |call| Time.now.hour > 20 }
route 'default', DefaultController
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};
@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
#!/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 / 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
1 #!/bin/ruby
2
3 tema = ARGV[0]
4
5 solos = {
6 'domination' => [180, 60]
@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