Skip to content

Instantly share code, notes, and snippets.

@reanim8ed
reanim8ed / sample.md
Created November 30, 2023 08:59
[Allow to set 0000 date in mysql] #mysql

If you absolutely need to set it to zeros and are aware of the implications and potential issues that might arise, then you can temporarily disable strict mode for your session, run the update statement, and then re-enable strict mode. Here's how you can do it:

  1. Disable Strict Mode Temporarily:

    SET @@session.sql_mode = REPLACE(@@session.sql_mode, 'NO_ZERO_DATE', '');
    SET @@session.sql_mode = REPLACE(@@session.sql_mode, 'STRICT_TRANS_TABLES', '');
  2. Run Your Update:

@reanim8ed
reanim8ed / sample.md
Created October 26, 2023 19:46
[Auto restart elasticsearch services after crash] #elastic
  • Edit elasticsearch service unit file using the following command
sudo systemctl edit elasticsearch.service
  • This command will create a file

/etc/systemd/system/elasticsearch.service.d/override.conf

  • Now, add the following lines in the unit file.
@reanim8ed
reanim8ed / sample.md
Last active July 20, 2023 16:23
[enable/disable firewall on Ubuntu 20.04 (UFW)] #ubuntu

$ sudo ufw status

  • As seen here, our firewall is currently active (on). For more detailed output regarding your current firewall settings, add the verbose option:

$ sudo ufw status verbose

  • To disable the Ubuntu firewall, execute the following command:

$ sudo ufw disable

@reanim8ed
reanim8ed / sample.md
Created July 20, 2023 16:18
[LEMP on Ubuntu 22.04] #ubuntu

LEMP - Nginx Web Server, MySQL / MariaDB Database, and PHP

Step 1: Update Software Repositories

sudo apt update
sudo apt upgrade

Step 2: Install Nginx Web Server on Ubuntu 22.04 LTS

sudo apt install nginx

@reanim8ed
reanim8ed / sample.md
Created July 20, 2023 16:11
[Make all new files in a directory accessible to a group] #linux
setfacl -d -m group:GROUPNAME:rwx /path/to/directory
setfacl -m group:GROUPNAME:rwx /path/to/directory

OR

Session follows:

/mnt/acl$ mkdir foo
@reanim8ed
reanim8ed / sample.md
Last active July 20, 2023 16:23
[LEMP in Ubuntu 20.04] #phpmyadmin #ubuntu #lemp

LEMP – Linux, Nginx (pronounced EngineX), MariaDB and PHP.

If you looking for a LAMP setup for your Ubuntu 20.04, then you should read our LAMP setup guide on Ubuntu 20.04.

Step 1: Installing Nginx on Ubuntu 20.04

  1. Nginx is a fast modern web server designed to server many concurrent connections without consuming too many server resources. This is why it’s often the preferred choice in enterprise environments.

NGINX is also commonly used as a load balancer and web content cache. It supports Name-based and IP-based virtual servers (analogous to virtual hosts in Apache).

You can install Nginx on your Ubuntu 20.04 desktop or server by running the following command.

@reanim8ed
reanim8ed / sample.md
Last active March 29, 2023 13:18
[UFW firewall] #ubuntu #firewall #ufw

UFW is installed by default on Ubuntu. If it has been uninstalled for some reason, you can install it with sudo apt install ufw.

Step 1 — Using IPv6 with UFW (Optional)

This tutorial is written with IPv4 in mind, but will work for IPv6 as well as long as you enable it. If your Ubuntu server has IPv6 enabled, ensure that UFW is configured to support IPv6 so that it will manage firewall rules for IPv6 in addition to IPv4. To do this, open the UFW configuration with nano:

sudo nano /etc/default/ufw

IPV6=yes

Now, when UFW is enabled, it will be configured to write both IPv4 and IPv6 firewall rules.

@reanim8ed
reanim8ed / sample.md
Created January 17, 2023 15:47
[Prestashop override classes] #prestashop

Sometimes you may need to extend a method that is currently set to be private. Unfortunately, it is not possible to extend private variables or methods in PHP.

This is a design issue. Core modules were written long before the introduction of module overrides. Difference is that private scope “locks down” class features, while protected scope is less strict and allows overrides by a child class.

If you come across a core module method that is private, the best thing to do is change it to protected.

@reanim8ed
reanim8ed / sample.md
Created December 23, 2022 17:35
[Bypass “Your connection is not private” Message] #chrome #ssl

Bypass “Your connection is not private” Message

Click a blank section of the denial page. Using your keyboard, type thisisunsafe. This will add the website to a safe list, where you should not be prompted again.

OR

In the Chrome address bar, type “chrome://flags/#allow-insecure-localhost“ Select the “Enable” link.

@reanim8ed
reanim8ed / sample.md
Last active November 9, 2022 09:04
[Change root password in mysql8] #mysq

Change root password

sudo systemctl stop mysql
sudo systemctl edit mysql

[Service]
ExecStart=
ExecStart=/usr/sbin/mysqld --skip-grant-tables --skip-networking

sudo systemctl daemon-reload