Skip to content

Instantly share code, notes, and snippets.

View bertrand-lupart's full-sized avatar

Bertrand Lupart bertrand-lupart

View GitHub Profile
@bertrand-lupart
bertrand-lupart / extensions-testsuite.conf
Last active January 31, 2018 11:03
Asterisk dialplan fragment to check span/group connectivity and voice quality from the asterisk console
; This dialplan fragment allow to dial a given number from the asterisk console on a given span :
; 1- check span ability to place a call
; 2- check logical group ability to place a call, as well as group allocation strategy
; 3- check caller ID presentation
; 4- check outgoing voice quality by announcing ${SYSTEMNAME} via speech synthesis
; 5- check incoming voice quality by Echo()'ing the called party
;
; Usage:
; $ sudo asterisk -rv
;
@bertrand-lupart
bertrand-lupart / loop_http_check.pike
Created January 3, 2018 17:16
Indefinitely test an URL, displaying HTTP return code and delay in nanoseconds
#!/usr/bin/env pike
int timeout_data=10;
int timeout=40;
string host_check = "www.example.com";
string query_check = "GET / HTTP/1.1";
int port_check = 80;
mapping headers = ([ "User-Agent":"Pike Loop HTTP test" ]);
@bertrand-lupart
bertrand-lupart / extensions-dynamic-conference.conf
Last active April 26, 2019 09:18
Asterisk dialplan fragment for dynamic conference management with MeetMe() - KISS summum
; Dial 999 to dynamically create or join a conference :
; c – Announce user(s) count on joining a conference
; I – Announce user join/leave without review
; x – Leave the conference when the last marked user leaves
; s – Present menu (user or admin) when * is received (send to menu)
; M( class ) – Enable music on hold when the conference has a single caller
; Either :
; d – Dynamically add conference
; D – Dynamically add conference, prompting for a PIN
exten => 999,1,MeetMe(,cIxDsM) ; PIN-protected
@bertrand-lupart
bertrand-lupart / extensions-interactive-dialplan-feedback.conf
Last active February 6, 2018 11:06
Asterisk dialplan fragment for interactive dialplan incorrect extension feedback
[acme-attendant]
; Simple Auto-attendant - call 1234 to get prompted a personnal extension
exten => 1234,1,Ringing()
same => n,Wait(3)
same => n,Background(enter-ext-of-person)
same => n,Dumpchan()
same => n,WaitExten(10)
same => n,Hangup()
@bertrand-lupart
bertrand-lupart / extensions.ael
Created February 16, 2018 15:53
Simplest blank asterisk AEL config file, which won't mess up with extensions.conf
// Simplest blank asterisk AEL config file
//
// This configuration file is reloaded
// - With the "ael reload" command in the CLI
// - With the "reload" command (that reloads everything) in the CLI
//
// NOTE! NOTE! NOTE!
// Asterisk by default will load both extensions.conf and extensions.ael files.
// Upon loading these files the dialplans generated from both with be merged,
// so you must make sure that you don't have any overlapping contexts or global
@bertrand-lupart
bertrand-lupart / csv_trim_all_whites.pike
Last active April 26, 2019 09:08
Pike script which trim all whites in CSV data
#!/usr/bin/env pike
// This script take a dirty CSV as input
// Output a white-trimed CSV : spaces, tabs, CR, LF
// Set up the following
string in_dirty_path = "";
string out_clean_path = "";
int i_ve_set_file_paths = 0;
@bertrand-lupart
bertrand-lupart / how_many_days_since.pike
Created November 8, 2018 16:38
How many days since…
(Calendar.dwim_day("2001-02-12")->distance(Calendar.now())->how_many(Calendar.Day));
@bertrand-lupart
bertrand-lupart / extensions-dynamic-conferences-meetme-to-confbridge.conf
Last active April 26, 2019 09:13
Asterisk extensions.conf fragment implementing MeetMe()'s dynamic pin-protected conferences using ConfBridge()
; You may miss MeetMe() from your old asterisk box
; Here's an asterisk fragment whose goal is to mimic the following MeetMe() line using Confbridge()
; exten => 42,1,MeetMe(,cIxDsM)
; call 42 to create/join dynamic pin-protected ConfBridge() conference
; adapt context and call number to your actual numbering plan
[your-random-context]
exten => 42,1,NoOp()
same => n,Goto(conference,s,1)
same => n,Hangup()
@bertrand-lupart
bertrand-lupart / sub-second_epoch_hilfe.pike
Last active April 26, 2019 08:48
sub-second epoch Pike
> object t = System.Time(); t->sec; t->usec; t->usec_full;
(1) Result: 1556201631
(2) Result: 393431
(3) Result: 1556201631393970
> object s = Calendar.parse("%Y-%M-%aT%h:%m:%s.%f","2019-04-25T15:10:03.193000+00:00");
> s->f_unix_time();
(1) Result: 1556197803.193
@bertrand-lupart
bertrand-lupart / encrypt_decrypt_ecb.pike
Last active July 9, 2019 16:05
Simple symmetric encryption / decryption using AES ECB and pre-shared 16 bytes key
#!/usr/bin/pike
// Pre-shared key. Should be 16 bytes, kept secret
string key = "secret16byteskey";
// Message to encode
string msg_from = "What's your name, James?";
int main(int argc, array(string) argv)
{
write("key : %O\nmsg : %O\n", key, msg_from);