SQL: sed-like replacement of a string

April 30th, 2025

Imagine the situation: you have an SQL table with some string in some column. There is a plenty of such rows, and you want to replace this string in each row with some other string, something like in Bash – sed ‘s/green apple/blue apple/g’.

The original table looks like this.

Select:

Result:

We want to change “from ACME” to “moved from ACME”.

First, let’s test our SQL statement with SELECT, no changes will be made:

Now do an SQL UPDATE in a sed-like style:

The result after an UPDATE:

So, to test the statement, do:

To replace, do:

If you need case-insensitive, use ILIKE instead of LIKE.

Asterisk: skip some action within timeout after a call

April 29th, 2025

Let’s skip playing an annoying greeting for the caller, if he already called us withing the last 10 minutes.

Create a macro:

And use this macro in your dialplan:

OpenSIPS: dialplan module usage examples

December 8th, 2024

Use case 1:
convert the username consisting of letters in incoming INVITE from your VoIP provider to digits
(e.g. INVITE: rt_user1@192.168.1.203 -> INVITE: 13511654321@192.168.1.203, where country-city-subscriber is 1-3511-654321):

Add to your dialplan table:

So, the SQL record is as follows:

Read the rest of this entry »

Linux Application Firewall

December 4th, 2024

OpenSnitch – a Linux firewall for applications – interactive outbound connections filtering.
https://www.linux-magazine.com/index.php/Issues/2022/259/OpenSnitch
https://github.com/evilsocket/opensnitch

A Bash web server

December 4th, 2024

Nice oneliners which may be useful to show some console output via HTTP.

An example of showing the iptables FORWARD chain:

Then go to http://ip.add.re.ss:8080 and you will see the output as a web page. In case of adding new rules renew the webpage and you will see the newly added rules.

To report file system disk space usage:

More info: https://www.linux-magazine.com/Issues/2021/250/Bash-Web-Server/(offset)/3/(tagID)/92#

Slackware Tagfiles

October 12th, 2024

Found some old notes concerning tagfiles. This all is for Slackware 14, but mainly should be useful for newer versions as well, though may have differences, I haven’t checked and compared. See below…

Read the rest of this entry »

opensips: getting media IP

June 9th, 2024

To get the IP address from the SDP part of incoming INVITE:

http://lists.opensips.org/pipermail/users/2024-June/048189.html

NetBSD 10: httpd with PHP support

April 24th, 2024

By default httpd is run under _httpd user. To start from command line and specify another user (e.g. nobody) type:

To start httpd automatically, edit /etc/rc.conf (not /etc/rc.local , not /etc/defaults/rc.conf):

Ubuntu 20.04 remove old unused kernels

April 13th, 2024

https://askubuntu.com/a/1253348

Check what current kernel You are running:

So, this system runs 5.6.13-050613-lowlatency kernel.

List all installed kernels in Your OS:

Uninstall kernels You don’t need:

flameshot

March 10th, 2024

flameshot – a good alternative for Deepin Screenshot which seems to be unavailable in *buntu 23.10