Later Ctrl + ↑

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();
});
1 y  

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;
});
1 y  

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
1 y  
1 y  
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');"
2018  
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
2018  

How to find IPs with highest count of requests in access.log

First command will show you IPs sorted by number and them count of requests:

cat access.log | awk '{print $1}' | sort | uniq -c

You will be able to find IP masks with highest count of requests:

...
    158 217.115.65.19
    152 217.115.92.114
   3236 217.118.64.107
   8631 217.118.64.115
    640 217.118.64.119
   5122 217.118.64.124
    980 217.118.64.14
     37 217.218.94.2
     41 217.218.164.34
...

Next command will show you IPs sorted by count of requests:

less access.log | cut -d' ' -f1 | sort | uniq -c | sort -bg

For example:

...
   3818 178.207.194.252
   4090 89.169.172.165
   4732 60.47.208.104
   6500 82.146.33.201
   6698 31.200.239.18
   9934 141.8.132.20
  18032 141.8.142.126
...
2018  

How to fix wrong javascript after using Tidy

Almost every time when I updating something I become mean! In newest versions of Tidy (newest – 2015, lol) I found disappoint problem that javascript codes stopped working. Because Tidy converted javascript codes in page e. g.:

<script>
    script.onload = () => resolve(script);
</script>

To:

<script>
    <![CDATA[
            script.onload = () => resolve(script);
    ]]>
</script>

Instead of (in early versions):

<script>
    // <![CDATA[
            script.onload = () => resolve(script);
    // ]]>
</script>

If you have the same problem then don’t worry. Most likely Tidy tidying codes to xml or xhtml format default now. I found due solution this problem -- use option “output-html”:

$code = $tidy->repairString($code, [
    ...
    'output-html' => 1,
], 'utf8');
2018  
Earlier Ctrl + ↓