Debugging php cli-scripts from a docker container in NetBeans

Hello. Recently I made a script to replace my real php interpreter in NetBeans settings.

As you probably know NB can’t run dockerized php cli scripts. here I will show you how I solved this problem. Now instead of using terminal I just press Run or Debug button in NB GUI to start my session. AFAICS this solution is pretty good.

I started from something really simple:

#!/bin/bash
docker exec test-php php \
    -dxdebug.mode=debug \
    -dxdebug.start_with_request=1 \
    `basename ${BASH_ARGV[0]}` \
    "${@:1:$#-1}"

But this is not universal and does not take into account all the parameters I can set in ‘Project Properties’ > ‘Run Configurations’:

KDE error: “execvp: exec format error”

Preamble

When start concrete program from application menu this error message appears, program does not start

I met this error with any version of Oracle SQLDeveloper 20+ which was installed from official rpm on Ubuntu + KDE via alien -dic.

There was no error in MATE. May not reproduce in GNOME due to shell execution fallback. Met only in KDE.

There is no error when launch via gio launch.

There is no error when launch directly from terminal.

It’s useless to add +x permissions on desktop-files.

Launching via kioclient5 exec fails with following error:

Unknown error code 100
execvp: Exec format error
Please send a full bug report at https://bugs.kde.org.

Making a project backup in a simple way

black and white plastic containers
Photo by Markus Winkler on Unsplash

It is 2022-07-07 today. Two days ago I’ve stupidly and accidentally lost literally all data from this server including this blog and some pet projects.

There was no regular backuping. All backups I had at the moment was dated may which is better than nothing at all. Well, either I became very tidy in my tech skills or life still teaches me nothing ¯\_(ツ)_/¯

I set up server from scratch and deployed my projects again from those backups. It took me about several hours during two days. Unfortunately, I absolutely don’t remember exactly what has been permanently lost. Shit happens.

Before that accident I didn’t bother with backups: I already have some ones, server is (almost) always stable and fine, bills are always paid in time, what may happen? This was wrong laziness.

This time I was lazy properly, as any tech guy should: if you don’t want to spend time on boring routine — automate it and don’t spend.

Since my VPS deployed without any containers-n-shit, my solution will be simple too: bash + mysqldump + gzip + rsync + crontab + second VPS as reserve remote storage.

This second you maybe already understand what I will do and talk about because our grandfathers already

At this second, you maybe already understood what I’ll do and tell and decided to close the tab, because even your grandfather didn’t do backups like that. Well, I don’t give a shit and anyway will tell my solution and attach gist which is ready to use.

Bash: processing arguments in a script when called from the shell

Read in Medium

Hi. In my spare time, I write a project for work purposes, which consists of a bunch of bash scripts. There is one entry point that connects the rest of the functionality via ‘source’. They contain functions that should only process the required arguments directly from the cli.

In early versions of the project, I just explicitly passed $1, $2, $N from top to bottom to other functions. It was a stupid solution, and it worked because the possible arguments and their order were known and simple. But it was disgusting aesthetically. I wanted to enjoy reading code and to unify a lot of things. To do this, the entire code had to be greatly complicated to make everything conceptually much simpler.

So, different functions must accept different arguments from input, and also I want to give to user an ability to pass:

  • long arguments with no values:
    ./script.sh --foo --bar
  • long arguments with values:
    ./script.sh --foo = bar
  • short arguments without values:
    ./script.sh -a -b -c
  • short arguments with values:
    ./script.sh -a avalue -b bvalue
  • combine any short short arguments into one word:
    ./script.sh -abc bvalue
  • all of above ones at the same time!
  • the order of the arguments shouldn’t matter
  • I hould have access to any of them from anywhere at any time.
Published
Categorized as blog-en Tagged