Best Of
Re: How to know when time zone has changed and when timezone will change in linux
The above command will give the list of dates when timezone changes, you can also try another command in linux.
timedatectl status
This will output all the details you need on timezone
Local time: Wed 2023-11-22 04:26:14 EST Universal time: Wed 2023-11-22 09:26:14 UTC RTC time: Wed 2023-11-22 09:26:12 Time zone: America/New_York (EST, -0500) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: no Last DST change: DST ended at Sun 2023-11-05 01:59:59 EDT Sun 2023-11-05 01:00:00 EST Next DST change: DST begins (the clock jumps one hour forward) at Sun 2024-03-10 01:59:59 EST Sun 2024-03-10 03:00:00 EDT

Adding LISTEN, WHISPER, BARGE to ASTERISK for SIP and PJSIP
For the purpose of this article, we will define manager as the caller who is the spying channel, agent who is the spied-on channel, and client who is the bridged channel / 3rd party. We define listen, whisper, and barge as follows:
Listen
Monitor an agents call. The manager can hear both the agent and client channels, but no-one can hear the manager.
Whisper
Whisper to the agent. The manager can hear both the agent and client channels, and the agent can also hear the manager, but the client can only hear the agent, hence “whisper.”
Barge
Barge in on both channels. The manager channel is joined onto the agent and client channels, and all parties can hear each other. Be warned, if the original agent leaves the call, the call is dropped. This is not a 3-way call.
(However you can barge in, and when comfortable, initiate a 3way call to your extension so you can continue the call without the agent. This procedure varies from client to client (soft/hard phones))
One more note: We can also provide 3-way calling [live transfer] services on the server side, however this is outside the scope of this document. Please contact us for details.
This should be placed in /etc/asterisk/extensions_custom.conf
[ext-local-custom] ;listen exten => _*222x.#,1,Answer() exten => _*222x.#,2,NoCDR() exten => _*222x.#,3,Wait(1) exten => _*222x.#,4,AGI(${FASTAGI}/outb_spy.php,listen) ;For SIP exten => _*222x.#,5,ChanSpy(SIP/${EXTEN:4},q) ;For PJSIP (comment above line and uncomment below) ;exten => _*222x.#,5,ChanSpy(PJSIP/${EXTEN:4},q) exten => _*222x.#,6,Hangup() ;whisper exten => _*223x.#,1,Answer() exten => _*223x.#,2,NoCDR() exten => _*223x.#,3,Wait(1) exten => _*223x.#,4,AGI(${FASTAGI}/outb_spy.php,whisper) ;For SIP exten => _*223x.#,5,ChanSpy(SIP/${EXTEN:4},qw) ;For PJSIP (comment above line and uncomment below) ;exten => _*223x.#,5,ChanSpy(PJSIP/${EXTEN:4},qw) exten => _*223x.#,6,Hangup() ;barge exten => _*224x.#,1,Answer() exten => _*224x.#,2,NoCDR() exten => _*224x.#,3,Wait(1) exten => _*224x.#,4,AGI(${FASTAGI}/outb_spy.php,barging) ;For SIP exten => _*224x.#,5,ChanSpy(SIP/${EXTEN:4},qB) ;For PJSIP (comment above line and uncomment below) ;exten => _*223x.#,5,ChanSpy(PJSIP/${EXTEN:4},qw) exten => _*224x.#,6,Hangup()
Let’s break it down:
Dialing *222970 would initiate listen on channel 970. *224401 would barge in on 401’s call speaking to both parties.
We start by finding (or adding) the ext-local-custom context, and declaring: exten => _*222x.# which will catch calls going to *222 followed by a sequence of numbers.
In ChanSpy app, there are various options you can use, we chose q (which prevents “SIP.6626″ or whatever from being spoken when you start spying.) w, which is “whisper mode”, and B which is barge. Do not get this confused with b (lowercase) which is for only joining bridged calls.

Re: PostgreSQL : failed: FATAL: no pg_hba.conf entry for host
First look for pg_hba.conf
, you can use locate command to do so
locate pg_hba.conf
Then edit the file on your favorite editor
vi /var/lib/pgsql/9.6/data/pg_hba.conf
Add the following line to the file
host all all 192.168.0.1/32 md5
In order to apply changes, you must reload the service. In my case, I have pg version 9.6 so commands will be
service postgresql-9.6 reload service postgresql-9.6 status

Monitor Log Files in Real Time using tail
tail Command – Monitor Logs in Real Time
As said, tail command is the most common solution to display a log file in real time. However, the command to display the file has two versions, as illustrated in the below examples.
- In the first example the command tail needs the
-f
argument to follow the content of a file.
sudo tail -f /var/log/apache2/error.log
- The second version of the command is actually a command itself: tailf. You won’t need to use the -f switch because the command is built-in with the -f argument.
sudo tailf /var/log/apache2/error.log

Re: Disable "Changes you made may not be saved" pop-up window
The message is the beforeunload event. And I can disable it with window.onbeforeunload = null;

Re: Create directory in date like structure
Create a shell script let's say move_files.sh
with the following snippet
function filemove() { FILE_NAME=$(basename "$1") if [[ "$FILE_NAME" =~ ^.+\_[0-9]{8}\-.+_.+_.+-.+\.mp3$ ]]; then FILE_DIR=$(echo $1 | awk -F'[_-]' '{print substr($2,1,4) "/" substr($2,5,2) "/" substr($2,7,9) "/" $5 "/";}'); echo "$FILE_NAME : >> : $FILE_DIR" echo "---------------------------"; echo -e "creating directory:: \e[1;32m $FILE_DIR\e[0m"; mkdir -p "$FILE_DIR"; echo -e "moving file:: \e[1;32m $FILE_NAME to $FILE_DIR\e[0m"; mv -f "$FILE_NAME" "$FILE_DIR"; else echo -e "\e[1;31m ::---------------Invalid file name $FILE_NAME---------------:: \e[0m"; fi echo "" } export -f filemove find ./ -maxdepth 1 -type f -name "*.mp3" -exec bash -c "filemove \"{}\"" \;
Now place this file inside the directory containing mp3 files
and finally form the terminal execute the shell file ./move_files.sh

How to show all values when AngularJS strict filter field is empty?
I have a table which can be filtered by several columns. The filter is strict. However, it shows an empty table. How to apply a strict filter only to non-empty values? I need to show all results when a strict filter input is blank.
<table id="searchTextResults"> <tr><th colspan="2">Strict filter</th></tr> <tr><th>Name</th><th>Phone</th></tr> <tr ng-repeat="friend in friends | filter:searchText:true"> <td>{{friend.name}}</td> <td>{{friend.phone}}</td> </tr> </table>
array of data,
[ {name:'John', phone:'555-1276'}, {name:'Mary', phone:'800-BIG-MARY'}, {name:'Mike', phone:'555-4321'}, {name:'Adam', phone:'555-5678'}, {name:'Julie', phone:'555-8765'}, {name:'Juliette', phone:'555-5678'} ]

Install Asterisk 18 on CentOS 8
Asterisk-installation
A little house keeping before installation.
yum update yum groupinstall "Development Tools" sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/sysconfig/selinux sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/selinux/config sestatus reboot sestatus sudo yum install httpd firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --permanent --add-service=http firewall-cmd --zone=public --permanent --add-service=https firewall-cmd --reload sudo systemctl enable httpd.service sudo systemctl start httpd.service
Installing DependenciesPermalink
yum install -y epel-release dmidecode gcc-c++ ncurses-devel libxml2-devel make wget openssl-devel newt-devel kernel-devel sqlite-devel libuuid-devel gtk2-devel jansson-devel binutils-devel
dnf --enablerepo=PowerTools install libedit-devel dnf --enablerepo=PowerTools install libsrtp dnf --enablerepo=PowerTools install libsrtp-devel
yum install -y libedit-devel libsrtp libsrtp-devel
Install Asterisk 18
cd /usr/src/
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz
tar -zxvf asterisk-18-current.tar.gz mv asterisk-18.3.0/ asterisk/ cd asterisk
contrib/scripts/install_prereq install
./configure --libdir=/usr/lib64 --with-pjproject-bundled --with-crypto --with-ssl=ssl --with-srtp --with-jansson-bundled make menuselect make make install make install-headers (optional if requires. Development headers are only installed if the “install-headers” target of make is done.) make samples make config
Start at server restart
ldconfig
sudo systemctl start asterisk
Entering into command line of asterisk
asterisk -rvv
core show help exit
Configure extensions.conf and pjsip.conf
cd /etc/asterisk mv extensions.conf extensions.sample mv sip.conf sip.sample mv pjsip.conf pjsip.sample
Creating a basic Dial Plan by editing extensions.conf
vi extensions.conf
[public] exten = 100,1,Goto(hello-world,s,1) [default] [hello-world] exten = s,1,Answer() same = n,Wait(1) same = n,Playback(hello-world) same = n,Hangup()
Create SIP members in pjsip.conf
vi pjsip.conf
[transport-udp] type=transport protocol=udp bind=0.0.0.0 [7000] type=endpoint context=public disallow=all allow=ulaw auth=7000 aors=7000 [7000] type=auth auth_type=userpass password=7000 username=7000 [7000] type=aor max_contacts=1
asterisk -rx "core restart now"
asterisk -rvvvvv
