Skip to main content

Joomla - Run a SQL statement outside Joomla and display a nice HTML table

5 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

Joomla - Run a SQL statement outside Joomla and display a nice HTML table

A long time ago, years from now, I needed to expose data from my Joomla site in a simple web page outside Joomla, as an HTML table. This was so that I could link a Microsoft Excel spreadsheet to this table and therefore, in Excel, simply do a Refresh to obtain the most recent data from my Joomla site.

The aim was to find the list of people who had bought software or services from me. Among other things, I needed their first name, family name, billing address, etc. so that I could create an invoice in Microsoft Word using the mail merge functionality (data source=Excel).

Real world use case

Oh, wait, so a web page that would execute a SQL query of the type SELECT ... FROM ... WHERE ... against the Joomla database, retrieve the records then display them in an HTML page so Excel can link the table and Word can retrieve them and generate f.i. pdf. Cool, isn't it?

Of course, just running a query on your database and show the result as a web page can be really useful.

FTP - Remove files and folders at light speed

2 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

FTP - Remove files and folders at light speed

Have you ever deleted a website from your FTP client? It's easy, just select the folder containing the website and press the delete key.

Easy, simple and ... so slow. It takes ages to suppress files / folders. Several dozen minutes! Ouch.

If you've a SSH connection to your web server and if you're comfortable with it; you can rm -rf the folder and it'll be done in seconds.

But what if you don't have SSH or fear to make errors?

There is an alternative, the erase.php script.

Ubuntu - Install from scratch

5 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

Ubuntu - Install from scratch

Today is a public holiday in Belgium, so I'm finally taking the time to install Ubuntu on my old PC.

The idea is to remove Windows and install Ubuntu Desktop 24.04 on the computer.

Let's go, you'll see, it's easy.

WinSCP - Synchronize host and remote

2 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

WinSCP - Synchronize host and remote

By the use of a script, it's possible to ask WinSCP to synchronize your host and remote machine i.e. if a file is newer on the host, copy it to your remote server and the opposite.

If a file has been added to your host, copy it to your remote server and vice versa.

I'm using such script for making a full backup of some of my folders to my Synology.

Using Postman to play with API

9 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

Using Postman to play with API

If you are developing your own API (whatever the language) or if you need to consume some, Postman can be really handy.

Calling an API and getting the response is one thing, quite simple in fact, but a nice feature of Postman is the ability to validate the response like making sure the returned type is, f.i. application/json, the HTTP status code is 200, the response body is a JSON object (or an XML string), that the body contains some required information and so on.

You can also validate the response against a given schema to make sure the structure is well the one expected.

In this article, we'll use Postman like a unit test tool i.e. run checks on our own API and make a lot of assertions. This is improving the quality of your code by highlighting potential errors and, for any refactoring you'll do in the future, by running the tests again, you'll make sure you've not broken something; that you don't have any regression. Make sure you've not broken an API when you upgrade some code is gold.

Bash - Echo on the console and in a logfile in the same time

2 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

Bash - Echo on the console and in a logfile in the same time

In my previous article Bash - Script to add logging features to your script, I've shared a way to write information in a logfile.

By running ls -alh /tmp you will get the list of all files in the /tmp folder and display the list on your console. By running ls -alh /tmp >> application.log you won't see the list in your console since everything will be written in the application.log file.

How can we display the output of a command like ls f.i. both on the console and in a logfile?

Bash - Script to add logging features to your script

7 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

Bash - Script to add logging features to your script

Also read Bash - Echo on the console and in a logfile in the same time

When you write Bash scripts and certainly when you foresee running them in a cron, you should implement a logfile. Every action fired by your script should be logging somewhere so you can start the script in a non-interactive mode and in case of need, consult the last logfile.

Below is a script I've developed in the form of a library, which means you can easily include it in your existing code without having to change anything.

You just need to include the file in your script (i.e. add a source log.sh line) then here and there foresee a log::write "Something to log". Easy no?

Encapsulate an entire Docusaurus site in a Docker image

14 min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

Encapsulate an entire Docusaurus site in a Docker image

Started on 2 November 2023, this article is already the hundredth I've published on this blog. To mark the occasion, I wanted to do something a bit special to honor the blog. What better way than to build a 100% Docker version, i.e. in the form of a downloadable Docker image that you can run with a single command line.

A single command to download the blog and run it on your machine (Linux, Mac or Windows) and have a fully working site; nice isn't it?

And as usual, you'll find all the information you need below so that you can do the same for your own Docusaurus installation.

Don't wait more

Start a console, run docker pull cavo789/blog && docker run -d -p 80:80 --name blog cavo789/blog to download a local copy of my blog and to start it. Once done, just open http://localhost on your computer and ... congratulations, you've just obtained an offline yet executable version!

Now, we'll learn to do the same for your own Docusaurus instance. Ladies and gentlemen, please follow the guide...

CodeSnap addon for VSCode

One min read
Christophe
Markdown, WSL and Docker lover ~ PHP developer ~ Insatiable curious.

CodeSnap addon for VSCode

The extension CodeSnap will take beautiful screenshots of your code in VS Code without effort.

Open your file in vscode, select the desired lines, press CTRL-SHIFT-P, run CodeSnap. You just need to select lines now.

CodeSnap partial example