Позднее Ctrl + ↑

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.

 95   1 год  

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;
});
 107   1 год  

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();
});
 138   2019  

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;
});
 92   2019  

How to remove records from active connections and ip_conntrack by IP

Someone can opens hundreds tabs with autoupdate pages in browser and make lot of persistent open connections to the server. If you want to drop his connections, you have to find him at first:

sudo cat /proc/net/ip_conntrack | grep 'ESTABLISHED' | wc -l
sudo cat /proc/net/ip_conntrack | grep 'ESTABLISHED'
netstat -tulpan | grep 'ESTABLISHED' | wc -l
netstat -tulpan | grep 'ESTABLISHED'

If you found a lot of connections from one IP, check it: (Replace 255.255.255.255 to necessary IP)

sudo cat /proc/net/ip_conntrack | grep 'ESTABLISHED' | grep '255.255.255.255' | wc -l
netstat -tulpan | grep '255.255.255.255' | wc -l
whois 255.255.255.255

Look to the web server logs whether the activity is suspicious:

cat /var/log/nginx/access.log | grep '255.255.255.255'

Then drop user connections:

sudo cutter 255.255.255.255
sudo conntrack -D conntrack --orig-src 255.255.255.255
sudo cat /proc/net/ip_conntrack | grep '255.255.255.255' | wc -l
sudo cat /proc/net/ip_conntrack | grep 'ESTABLISHED' | wc -l
 165   2019  
 112   2019  
 214   2018  

How to setup composer globally

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=/usr/bin --filename=composer
php -r "unlink('composer-setup.php');"
 146   2018  
 147   2018  

How to fix Chromium forgets cookies at reboot

Warn: this topic have hatred.

I had updated Chromium on the other day. You know... some sites didn’t want to show some very useful content like videos of raccoons when you’re using old browser. Even if your browser had updated two months ago. So I had done it. I had updated Chromium and do you know what I had gotten? Nothing bad. It had been continuing its work. But for a while. Did I already said that I like hate flarking updates? After week or two weeks I closed browser and open it again. And it required interference. No, it didn’t frozed up. And it did’t want to hug. It forgot all cookies!

As the matter of fact it is no neccessary to descend deeper than may seem for looking for decision. The solution was on surface.

I dunno why but after flarking updates Chromium decided to change my privacy settings (and may be some options more). In a specific case how browser relates to keeping cookies at reboot.

So only what you need to do it is disable option “Keep local data only until you quit your browser” in Cookies settings which you can find at

chrome://settings/content/cookies
 157   2018  
Ранее Ctrl + ↓