Export data frame to DBeaver compatible CSV

DBeaver does not support the escape character and the quote character to be the same.

To export a pandas data frame to a DBeaver compatible CSV you can use the following command:

df.to_csv('data.csv', quoting=csv.QUOTE_NONNUMERIC, quotechar='"', escapechar='\\', encoding="utf-8", index=False, doublequote=False)

VS code dialogs do not appear in foreground (cinnamon)

That is a common bug in electron applications when they are using GTK (see here and here).

Add to your .bashrc the line:

export GTK_USE_PORTAL=1  

Then edit the menu of the operating system as follows:

  • Right click on the menu
  • Select configure
  • Open the menu editor
  • Select the application
  • Click properties
  • Add the following:
env GTK_USE_PORTAL=1 /usr/share/code/code --unity-launch %F

Screenshots:

OSI layers

Table of contents

  1. Explanation
  2. Visualization
  3. Mapping to TCP/IP model

Explanation

  1. Physical Layer: This is the lowest layer of the OSI model and deals with the physical transmission of data. It defines the electrical, mechanical, and procedural standards for transmitting raw data over a physical medium, such as cables or wireless signals.
  2. Data Link Layer: This layer focuses on node-to-node communication, providing reliable data transfer across the physical network. It manages error detection and correction, as well as flow control. Ethernet switches operate at this layer.
  3. Network Layer: The network layer is responsible for routing packets from the source to the destination across multiple networks. It determines the optimal path for data transmission, based on factors like network congestion and traffic patterns. Routers operate at this layer.
  4. Transport Layer: This layer ensures reliable end-to-end communication between hosts. It segments and reassembles data from the upper layers, handles error detection and recovery, and manages flow control. TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) operate at this layer.
  5. Session Layer: The session layer establishes, manages, and terminates communication sessions between applications. It handles session setup, coordination, and teardown, allowing applications on different devices to communicate with each other.
  6. Presentation Layer: This layer is responsible for data translation, encryption, and compression, ensuring that data exchanged between applications is in a format that the receiving application can understand. It handles tasks like data encryption, data compression, and character encoding.
  7. Application Layer: The application layer is the topmost layer of the OSI model and provides network services directly to end-users and applications. It enables communication between different applications and supports various application protocols such as HTTP, SMTP, and FTP.

Visualization

Mapping to TCP/IP model

Laravel testing – disable throttling

Use this code at your base class:

use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Routing\Middleware\ThrottleRequests;

abstract class TestCase extends BaseTestCase
{
use CreatesApplication;

protected function setUp(): void
{
parent::setUp();

$this->withoutMiddleware(
ThrottleRequests::class
);
}
}

Vue JS – htaccess file for history mode

Here is a working example:

<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>

Or another solution: (tested in siteground)

RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^(.*)$ https://myURL.com/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.html [L]

Laravel-VSCODE X-debug configuration

Table of contents

  1. Install x-debug
  2. Configure x-debug
  3. Run the x-debug listener in VS-Code
  4. Configure the task to launch laravel
  5. Debug the project

In this article we assume that php is already installed.

Install x-debug

sudo apt-get install php-xdebug

Configure x-debug

Run phpinfo() to find which php.ini you need to edit:

php -i | grep "Loaded Configuration File"

For example the path might be:

/etc/php/8.3/cli/php.ini

You need to edit the php.ini file to configure (x-debug 3). You may change the values according to your needs. The default port of x-debug is 9000 but it is highly recommended to change it because more often that not that port is used by another application.

[xdebug]
xdebug.mode=debug
xdebug.client_port=11887
xdebug.client_host=0.0.0.0
xdebug.remote_handler=dbgp
xdebug.start_with_request=yes
xdebug.discover_client_host=0
xdebug.idekey=VSCODE
xdebug.show_error_trace = 1
xdebug.max_nesting_level=250
xdebug.var_display_max_depth=10
xdebug.log=/tmp/xdebug.log

Run the x-debug listener in VS-Code

In VS Code, install the plugin for x-debug

Then add in the launch.json:

{
"version": "0.2.0",
"configurations": [
{
"name": "Listen with Xdebug",
"type": "php",
"request": "launch",
"port": 11887
}
]
}

You can run press F5 to start the listener. Once you do, you may launch the Laravel project however you want and it should stop at the break points.

It is recommended to run the listener BEFORE the Laravel application.

Configure the task to launch laravel

Create the task to launch Laravel.

For example:

{
"version": "2.0.0",
"tasks": [
{
"label": "php artisan serve",
"type": "shell",
"command": "php artisan serve",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": [],
"isBackground": true
},
{
"label": "php artisan test",
"type": "shell",
"command": "php artisan test",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "shared"
}
}
]
}

Debug the project

In order to debug the project, You need to do the following steps:

  • Press F5 to launch the x-debug listener
  • Press CTRL+SHIFT+P to run the task that runs Laravel (php artisan serve)

Visual Studio Code Settings

Table of contents

  1. Create config file
  2. Tips and Tricks
    1. Ignore files in search
    2. Exclude files from explorer
    3. Theme per project
    4. Favorite files and directories
    5. Run php artisan commands as tasks
  3. Configuration examples
    1. Laravel

Create config file

Create a file named settings.json in .vscode directory and add custom configuration:

mkdir .vscode
touch .vscode/settings.json

Tips and Tricks

⚠️ Important: files already open on the editor will not be ignored even if excluded in the settings.

{
"search.exclude": {
"**/node_modules": true,
"**/src/assets": true,
"**/public": true,
"package-lock.json": true,
"CHANGELOG.md": true,
"README.md": true,
}
}
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"_original_template": true,
"nbproject": true
},
{
"php.version": "v8.2.0",
"search.exclude": {
...
},
"workbench.colorTheme": "Default Dark Modern",
"workbench.colorCustomizations": {
"editor.background": "#001C40"
}
}

Install the favorites plugin

Then you can define favorite files:

{
...
"favorites.resources": [
{
"filePath": "routes/api.php",
"group": "Default"
}
]
}

Create a task (tasks.json) and press ctrl+shift+P to launch it.

{
"version": "2.0.0",
"tasks": [
{
"label": "php artisan serve",
"type": "shell",
"command": "php artisan serve",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "new"
},
"problemMatcher": [],
"isBackground": true
},
{
"label": "php artisan test",
"type": "shell",
"command": "php artisan test",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "shared"
}
}
]
}

Configuration examples

Laravel

{
"php.version": "v8.2.0",
"search.exclude": {
"**/bootstrap": true,
"**/vendor": true,
"**/node_modules": true,
"**/storage": true,
"**/src/assets": true,
"**/public": true,
"package-lock.json": true,
"CHANGELOG.md": true,
"README.md": true,
},
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"_original_template": true,
"node_modules": true,
"vendor": true,
"nbproject": true
},
"workbench.colorTheme": "Default Dark Modern"
}

Personal portal to the Internet