Skip to main content

Docker-in-Docker aka dind

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

Docker-in-Docker aka dind

In very exceptional situations, you may need to be able to run Docker commands from a Docker container. Wait? What?

Imagine this situation: you're running a PHP container, everything is fine and you wish to run a code quality tool like, let's start easy, phplint (see this article for deeper info). You don't want to install phplint because you know a very cool Docker image who already contains it (think to jakzal/phpqa)

So, you're inside a container and you wish to run another container.

Another example: you're still inside a container and you wish to access to the list of running containers, already installed Docker images, volumes, ... (think to portainer)

Let's see in this article how to create your own Docker image, running as root or not, and configure it to allow Docker-in-Docker requests.

Python - Generate flows using pydot

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

Python - Generate flows using Pydot

Pydot is a diagram as code generator i.e. you write lines of code and thanks to a magic process, you can render the code as an image.

For guys just like me who are terrible at visuals, this is gold.

Let's say you have to describe an IT process such as ETL (data is loaded, one or other transformation rule is applied and the result is loaded into a database, for example), you can easily imagine to draw some rectangles using a tool like https://app.diagrams.net/ (formerly known as draw.io) or use a smarter way to do it.

Let's see how in this article.

Markdown - Convert CSV to Markdown tables

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

Markdown - Convert CSV to Markdown tables

See also Markdown - Convert Excel ranges to Markdown tables.

Next to my XLS2MD script, you can also convert CSV file to Markdown very easily.

Just copy/paste your CSV content like the one below on the main text area appearing on Markdown - Convert CSV to Markdown tables and enjoy.

Column 1 Header,Column 2 Header
Row 1-1,Row 1-2
Row 2-1,Row 2-2

Markdown - Convert Excel ranges to Markdown tables

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

Markdown - Convert Excel ranges to Markdown tables

See also Markdown - Convert CSV to Markdown tables.

I'm a big fan of Markdown for my documentation, and from time to time I have to convert a range in Excel into a table to copy and paste into my documentation.

Years ago, I've found this repo https://github.com/jonmagic/copy-excel-paste-markdown and it's was the trigger for creating an online application in VueJS to make the magic happens.

In practical terms, I open my Excel file, select a range (a series of columns and rows) f.i. $A$1:$J:$50, press CTRL+C on the keyboard, switch to my Markdown - Convert Excel ranges to Markdown tables website, press CTRL+V and the table is converted.

Pandas - Merge two or more files and create a merged one

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

Pandas - Merge two or more files and create a merged one

You've two or more files and you wish to merge them. For instance, a list of employees and their salary for 2020 up to 2024. Or a list of cost centers and their budget/expenses. Or a list of students and their evaluation score. Or ...

Let's look at an example: a list of employees and their salaries.

We've many files, one by year, with this structure:

id;first_name;last_name;salary
0;Gina;Andrade;6040
1;Adam;Rowe;3866
2;Michael;Martinez;6913

And our need is to merge yearly files and generate a merged one with employees and their salary across years so, at the end, we wish to obtain this:

id;first_name;last_name;salary_2020;salary_2021;salary_2022;salary_2023;salary_2024
0;Gina;Andrade;6040;4413;7773;6208;7363
1;Adam;Rowe;3866;3678;2726;5425;7570
2;Michael;Martinez;6913;6493;5664;4902;4657

Using Pandas will make this piece of cake...

Docker - Even easier setup of Python

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

Docker - Even easier setup of Python

Nothing to install, nothing to configure, nothing to create first.

Here is how to use VSCode and Docker to create a ready-to-user Python environment, whatever if you're under Windows, Linux or Mac.

The only prerequisites are: we should have Docker installed on your system, you should have Visual Studio Code and you've installed the Docker for Visual Studio Code addon in VSCode.

Docker - Easy setup of Python under Windows

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

Docker - Easy setup of Python under Windows

In a previous article, I've provided some files to be able to quickly create a Python environment under Linux. Today, let's play and use the exact same files but this time under Windows.

The today challenge is easy: create a Python environment on my Windows machine without to have install Python of course and without to have to configure VSCode. Just run some magic and, voil脿, as a Python newcomer, I can start to code without first losing time to configure my computer.

Format poorly formatted PHP code

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

Format poorly formatted PHP code

You're recovering some old PHP code; you want to answer a question asked on a forum and the person who posted the PHP question didn't take care to ensure that it was properly formatted; ... there are too many occasions when the syntactic quality of a code can be rotten.

You'd like to have an online tool that you can use to quickly retrieve code with a much more polished layout, just by copying and pasting. Without having to install anything and without any headaches.

For example, how do you make the code below look cleaner in five seconds?

<?php
abstract class mycollection implements Iterator
{
protected function populate($array, $dataobject){
foreach($array as $item){
$object = new $dataobject();
foreach($item as $key => $val){$object->$key = $val;}
$this->storage[] = $object;
}}
}

VBS - Get list of files and generate a CSV

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

VBS - Get list of files and generate a CSV

Six years ago, I needed a DOS script that would allow me to find the list of every file in a folder on a Windows machine and generate a .csv file with that list.

Once the .csv file had been generated, I could then process it in MS Excel, for example, and sort/filter it or, why not, in Python using the Pandas library.

Keep running and count the number of files in a folder using inotifywait

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

Keep running and count the number of files in a folder using inotifywait

Over the last few weeks, I've been working on a Python script that generates PDFs. My script had to generate 70,000 of them and that obviously takes a while.

My idea was to have my script run in a Linux console and, in a second console, with a counter that increases with the number of files that have been created on the hard disk.

The first script will be in Python and I wanted something ultra-simple and using a simple Linux command.

The command ls folder_name | wc -l works but didn't stay running. Let's see how we can do better with inotifywait.