Skip to content

Instantly share code, notes, and snippets.

View dhfromkorea's full-sized avatar

dh dhfromkorea

View GitHub Profile
<Response>
<Dial action="https://app.close.io/calls/forward_or_voicemail/" sipHeaders="Call-ID=acti_WFzoC1SQhHiLgCiAAQOKCExwcCwdrskXIoH57gCBHY1,Organization-ID=orga_3XfAe7NxJVQ6sxplkj6LHOF8Towrb90zHOTAyDTxJGh" timeout="30">
<User>sip:closeio_sip_user@phone.plivo.com</User>
</Dial>
</Response>
<Response>
<Dial action="https://app.close.io/calls/voicemail/" confirmKey="1" confirmSound="https://app.close.io/calls/press_1_to_accept/" timeout="30">
<User sipHeaders="Call-ID=acti_dOqGeD17hRQRaP7t5QUcTVsZjYb3JuOSRsNKgwBYRYy,User-ID=user_3Fd6uKJx1YEnNzdxLYpinzrEKe0tLtFq4PmcOYlAFQp,Organization-ID=orga_TdFaRupCS0Cb7E1agBfcXu2DFXUQyN3k4LitSINID8v">sip:closeiocloseio_sip_user_1@phone.plivo.com</User>
<User sipHeaders="Call-ID=acti_dOqGeD17hRQRaP7t5QUcTVsZjYb3JuOSRsNKgwBYRYy,User-ID=user_JzXh7wUoXMP1oRRPJM7tCujOWMSTruIXSCCHTtZ8y9S,Organization-ID=orga_TdFaRupCS0Cb7E1agBfcXu2DFXUQyN3k4LitSINID8v">sip:closeio_sip_user_2@phone.plivo.com</User>
<Number>18008889999</Number>
</Dial>
</Response>
{
'Direction':'inbound',
'X-PH-Contact-ID':'cont_XpV6S7xJz4TMMzR7fyjrqtIOFkuZc256G6yjFtiZXXw',
'From':'sip:closeio_sip_endpoint_username@phone.plivo.com',
'CallerName':'closeio_sip_endpoint_username',
'X-PH-Call-ID':'acti_WYzqqMLJSraAB8Pzwm3vcYixW5wEyIyk5tdkBYvG2vZ',
'BillRate':'0.1',
'X-PH-Organization-ID':'orga_IwDwdnJk2n2GZAGxN0U4ZRJVM8tndgCCFf9jJypQ0Pu',
'To':'15556667777',
'X-PH-Lead-ID':'lead_ZUpJKIfsyt6PIf4enKfr42zZFhsQguVviHNXDqE32oB',
<Response>
<Dial callerId="16501112222" dialMusic="real">
<Number>15556667777</Number>
</Dial>
</Response>
@dhfromkorea
dhfromkorea / filename_fetcher
Last active August 29, 2015 14:07
fetch all the links of files of a certain extension in a webpage.
// by default, it fetches pdf
// change pdf to an extension you want
var pdflinks = [];
Array.prototype.map.call(document.querySelectorAll("a[href$=\".pdf\"]"), function(e, i) {
if ((pdflinks || []).indexOf(e.href) == -1) {
pdflinks.push(e.href);
}
});
console.log(pdflinks.join(" "));
// copy the logged file names
@dhfromkorea
dhfromkorea / phase_portrait.R
Created August 1, 2015 20:38
plotting a phase portrait of non-linear autonomous ODE's using phaseR
if (!require(phaseR)){
install.packages('phaseR')
require(phaseR)
}
# a system of two non-linear autonomous ODE's
ode = function (t, y, parameters) {
x <- y[1]
y <- y[2]
dy <- numeric(2)
@dhfromkorea
dhfromkorea / memoized_fibonacci.js
Created August 3, 2015 18:12
memoized_fibonacci
var fibonacci = function(){
var _cache = [];
var fib = function(i){
if (i < 0) {
console.err('invalid input. i must be >= 0');
return;
}
if (i < 2) {
_cache[i] = i;
@dhfromkorea
dhfromkorea / fizzbuzz.js
Created August 3, 2015 18:27
fizzbuzz.js
var fizzbuzz = function(n){
var answer = '';
if (n % 3 === 0) {
answer = 'Fizz';
}
if (n % 5 === 0) {
answer += 'Buzz';
}
if (!answer){
answer = n;
@dhfromkorea
dhfromkorea / example.py
Last active September 11, 2017 19:48
audiofingerprinting example
fp = FingerPrint(path_to_dejavu_config_file)
timestamp_pb = 20000 # program boundary timestamp in secs from
PAD = 10 # temporal padding to apply to the timestamp
# slice an audio segement off the video
fp.slice_audio_segment(path_to_full_video_or_audio, pb - PAD, pb + PAD, "mp4")
# extract the fingerprint of the segment and save it to db
# db's configured in the .config file
# the path for the full video/audio and the segment may be different
@dhfromkorea
dhfromkorea / keyword.py
Created September 11, 2017 19:55
keyword example
# this model is the most naive one
# find the occurences of the keywords listed and consider them to be matched.
# TODO will be to apply a Bag of Words model or some sort and assign credit score
# read raw caption files
caption_data, metadata = next(load_caption_files(path_to_caption_file))
# combine captions by 10 seconds (i.e. make time blocks)
X = split_caption_to_X(caption_data)
keywords = ['caption', 'type=story', 'type=commercial']