Speak to the point


Генератор запоминающихся паролей
 11   5 d  
 13   5 d  

How to turn off monitoring and saving CHMOD in Git

Main command:

git config --global core.fileMode false

Unfortunately, it will be working for new cloned repositories only. Why? Because, when you cloned repositories earlier, Git placed the choice “fileMode = true” in their files of a configuration. And now you need to use this command in every cloned repository for fully fixing CHMOD issue:

cd your_first_repository/
git config --unset core.fileMode
cd your_second_repository/
git config --unset core.fileMode
... and next

Now, earlier cloned repositories will use the global configuration at the beginning of this instruction.

 9   5 d  

How to set the MySQL root password in the Debian 9 (or MySQL 5.7+, MariaDB 10.1+)

You can think that there is no problem to set the root password in installation time. It’s true until 5.7 version of MySQL (or MariaDB 10.1). Now you can be authorized under root (and without password), but only through the auth_socket. For example, authorization under root in mysql-client:

mysql -u root

It means that the phpMyAdmin or other scripts will not be able to use root access more.

Now the next methods do not work:

mysqladmin -u root password
SET PASSWORD FOR root@localhost=PASSWORD, UPDATE user SET Password=PASSWORD

What can we make to use root privileges as earlier? We can create new user with root privileges and use it. Let’s do that.

First step:

mysql -u root

Create new a user with root privileges:

CREATE USER 'root2'@'localhost' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON *.* TO 'root2'@'localhost';
FLUSH PRIVILEGES;

Where root2 and PASSWORD change to what you want.

Unfortunately, the user created by such method will not be able to give privileges to other users through the same phpMyAdmin. Therefore the following command can be useful to you for giving privileges to users through mysql-client:

GRANT ALL PRIVILEGES ON `DB_NAME`.* TO 'DB_USER'@'localhost' WITH GRANT OPTION;

Where DB_NAME and DB_USER change to what you want again.

 14   6 d  

How to import big MySQL dump quickly

Warning: This trick is only for InnoDB storage engine.

Open MySQL config file “/etc/mysql/my.cnf”:

mcedit /etc/mysql/my.cnf

Write into [mysqld] section:

[mysqld]
...
innodb_flush_log_at_trx_commit = 2

What does that mean? Now, data will be recorded not more often than once per second! It will very unload file system and increase speed of import.

But you need check that you haven’t this option:

...
general_log = 1
...

Because everything will be worthless with that option! Every SQL query will be written on the disk and import will be worked slowly.

You need to disable “slow_query_log” if it enabled too.

Well, if you don’t have that options or you have deactivated it, for the next step you need to restart the database server:

service mysql restart

I have to notice you, if your dump archived in gzip, you need to unpack it and import only raw dump! Because unpacking on the fly and importing at the same time works slowly.

So, let’s import:

mysql -u username -p db_name < dump.sql

After all don’t forget to delete or restore “innodb_flush_log_at_trx_commit” option from config “/etc/mysql/my.cnf” and reload mysql server!

Sources: ruhighload and mysql.com.

 16   7 d  
 14   7 d  

Fix issue with “Insert the picture” button in the Summernote

Summernote deactivates “Insert the picture” button when you use the context menu by mouse to insert the link.

You can use next code to fix this issue:

$('body').on('paste', '.note-image-url', function(e) {
    $('.note-image-url').val(e.originalEvent.clipboardData.getData('text'));
    $('.note-image-btn').removeAttr('disabled').removeClass('disabled');

    return false;
});
 20   9 d  
 11   9 d  

Fix: the text hides under the toolbar in Summernote

If you put several Summernote editors in Bootstrap tabs, then after navigating between tabs, the text in the editor hides under the toolbar. At the same time it is enough to scroll the page down or up and then everything falls into place.

We as users can patch it:

$('.yourSelector[data-toggle="tab"]').on('shown.bs.tab', function (e) {
    $('.note-editor').scroll();
});
 30   19 d  

Fix: Option “disableDragAndDrop: true” doesn’t works in Summernote

In my case, this option doesn’t works:

$('.editorField').summernote({
    ...,
    disableDragAndDrop: true // Не работает...
});

I think it is a summernote bug. Maybe it will be fixed in new versions or it has already fixed, but I don’t want to update editor now. Therefore I made a dirty hack in my code:

$('body').on('drop', '.note-editable', function() {
    return false;
});
 39   19 d  
Earlier Ctrl + ↓