Skip to main content

Batch edit of environment file

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

Batch edit of environment file

When deploying a project on servers, we need to pay particular attention to the .env file. This file is crucial and will determine whether our application works properly (or crashes).

The normal way of doing things is to run a git clone command to get the latest version of the application from a repository (branch test for a test server, dev for an acceptance server, main for a production server).

Once cloned, the next command will be to create the .env file and it's done using cp .env.example .env.

And that's where the obligation to be meticulous begins.

Search and replace (or add) using sed

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

Search and replace (or add) using sed

Today, I was facing (once more) with the following need: I need to update a setting in a text file but if the variable is not yet present, I need to add it.

So, in short, I need to make a search and replace or insert new line.

Using sed it's quite easy to automate the search & replace but how to append?

Exterminate them all, fight spam directly at your host company

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

Exterminate them all, fight spam directly at your host company

If your web host company offers you a cpanel access, you will find there access to a tool called SpamAssassin.

There, you've two main options: the Spam filter and a White list.

Using the first one, you can define email patterns like *@hair.com which mean: immediately kill those emails on the server. The second one is just the opposite f.i. *@my-own-company.com saying that you trust that domain.

PlanetHoster - N0C

If you're hosted by PlanetHoster on the N0C infrastructure, please read Exterminate them all, fight spam directly at PlanetHoster - N0C instead.

WinSCP - Retrieve a stored password

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

WinSCP - Retrieve a stored password

More than once I've found myself in the situation where I've got a site saved in the WinSCP configuration where I've saved the password and, um, gosh, what was it?

Did you know WinSCP provide an option to show you, in plain text, a stored password?

Autosave feature in VSCode

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

Autosave feature in VSCode

How many times have you modified a file in vscode (and forgotten to save the modification) in order to refresh it from your web page, run the script from your console, etc., and then thought Oh no, damn, it still doesn't work?

And it can take several minutes and back and forth before, damned, silly me, I didn't save my modification.

And even more so when you've done a Search&Replace in several files; some having been saved and others not.

Let's see how to avoid this.

Rendering a JSON file as a mind map

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

Rendering a JSON file as a mind map

https://jsoncrack.com/editor

I really like the idea of not having to draw (actually, that is just because I am really bad at it) a diagram, a flow chart, a graphic representation of something that ... can be written.

Json crack is one of the tools in my toolkit when I want to draw something that can be written in json.

GitHub - Use Actions to deploy this blog

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

GitHub - Use Actions to deploy this blog

The last two months, I was using a FTP automation script to deploy the blog on my FTP server.

This way of doing things worked fine but had several inherent problems, the most important of which was that I had to run the script manually (from my computer).

If I modified an article directly from the Github interface or from another computer (where WinSCP was not installed, for example), there was no deployment.

By using Github actions, this problem no longer exists. With each push, the blog will be updated.

Getting the number of published posts

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

Getting the number of published posts

Docusaurus didn't provide an easy way to retrieve the number of blog posts but there is well a trick.

There is an automatic page called archive like /blog/archive/.

On that page, all blog posts are displayed by year and months. With a document.querySelectorAll console instruction it's possible to make the count as suggested on https://github.com/facebook/docusaurus/discussions/9712

Don't query your PostgreSQL db anymore, prefer PostgREST

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

Don't query your PostgreSQL db anymore, prefer PostgREST

Last year I had a large application developed in Laravel that required a MySQL database. When I was migrating to PostgreSQL I discovered PostgREST, which allowed me to completely remove queries from my code.

Don't get me wrong: my Laravel/PHP code was launching dozens of queries to the database and, after migration, none at all.

My tables, my models, my SQL queries, I was able to remove everything from my code. My PHP code has been greatly lightened and simplified.