Skip to content

Instantly share code, notes, and snippets.

@ambiorixg12
ambiorixg12 / gist:0955b6c8459145db3379e739817fd368
Last active May 6, 2024 18:12
docker lamp and phpmyadmin
version: '3.9'
services:
# MySQL Service
mysql-container:
image: mysql:8.0.30
container_name: mysql
restart: always
<?php
// Initialize a cURL session
$ch = curl_init();
// Create a query string from the array of parameters
$params = array(
"username" => "sms",
"password" => "1982",
"phonenumber" => "18097143489",
"message" => "122",
::::::::::::::BOT CODE :::::::::::::::::::::::
import openai
import os
# Get the OpenAI API key from an environment variable
openai.api_key = os.getenv("OPENAI_API_KEY")
class Chatbot:
def __init__(self):
self.messages = []
@ambiorixg12
ambiorixg12 / chatgpt.php
Created August 12, 2023 01:59
chatgpt working model with asterisk
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.openai.com/v1/chat/completions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer sk-dLwvCvDVK',
'Content-Type: application/json',
]);
@ambiorixg12
ambiorixg12 / asterisk realtime insert
Created June 17, 2023 00:28
asterisk realtime insert
---------------------------php code----
php /home/ambiorix/insert_device.php 2222
<?php
$link = mysqli_connect("localhost", "root", "mypass", "asterisk");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
@ambiorixg12
ambiorixg12 / gist:b8ad38a33c6d71d87bf71764befc7549
Last active April 11, 2023 00:29
playing an audio file after specif time
;;;custom notification;;;;
[playing-audio]
exten=>_x.,1,Noop( ----- Playing message on channel ${CHANNEL} -----------------)
same=>n,Set(__chan=${CHANNEL})
same=>n,Set(__inboundid=${EXTEN})
same=>n,Set(__time-play=20)
same=>n,Dial(Local/1923@spy-exten)
@ambiorixg12
ambiorixg12 / requesting a flow from a function
Created July 4, 2022 22:44
requesting a flow from a function
exports.handler = function(context, event, callback) {
var to_num =event.From;
var did =event.To;
// Here's an example of setting up some TWiML to respond to with this function
const TwilioClient = context.getTwilioClient();
TwilioClient.studio.v1.flows('FWac0dsssssss4')
.executions
.create({to: 'did', from: 'to_num',parameters: {
phone: to_num
}})
@ambiorixg12
ambiorixg12 / survey
Created April 17, 2022 02:56
survey
[survey_1]
exten=>_X.,1,Answer()
same=>n,Set(path=/var/www/html/recording_temp/)
same=>n,playback(welcome)
same=>n(rec_last),playback(vm-rec-name)
same=>n,Record(${path}${UNIQUEID:}_name.wav,,,ky)
same=>n,Set(name=${path}${UNIQUEID}_name.wav)
same=>n,Playback(auth-thankyou)
same=>n(rec_last),playback(vm-rec-name)
@ambiorixg12
ambiorixg12 / php server info
Created February 9, 2022 02:53
php server info
<?php
$server_check_version = '1.0.4';
$start_time = microtime(TRUE);
$operating_system = PHP_OS_FAMILY;
if ($operating_system === 'Windows') {
// Win CPU
$wmi = new COM('WinMgmts:\\\\.');
@ambiorixg12
ambiorixg12 / Twilio phone number time zone
Created January 14, 2022 20:49
Twilio phone number time zone
exports.handler = function(context, event, callback) {
let to = event.To;
const nums = [to,+1,+2,+3];
let n1 =nums[0];
let n2= nums[1];
let n3= nums[2];
let n4 =nums[3];
const number_tzone = {n1:"America/New_York",n2:"America/Miami"};