Позднее Ctrl + ↑

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
 160   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
...
 131   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');
 141   2018  

How to fix issue when Munin doesn’t zoom/show graphs by day

For nginx:

sudo apt-get install spawn-fcgi libcgi-fast-perl libapache2-mod-fcgid
sudo spawn-fcgi -s /var/run/munin/fcgi-graph.sock -U www-data -u www-data -g www-data /usr/lib/munin/cgi/munin-cgi-graph

For Apache2:

sudo apt-get install libapache2-mod-fcgid
sudo a2enmod fcgid
sudo service apache2 restart
 134   2018  
 72   2018  

How to get list all user agents ordered by the number of times they appear from access.log

awk -F\" '{print $6}' access.log | sort | uniq -c | sort -bg

Response example:

...
  46547 Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36
  89768 API/1.0 (+Legacy)
 104304 Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36
 133439 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36
 149988 Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)
 400785 Bad Bot
 93   2018  

How to block UserAgent with nginx

Open host file:

sudo mcedit /etc/nginx/sites-available/...

And put into server section condition:

if ($http_user_agent ~* (BadUserAgent) ) {
    return 404;
}

Where “BadUserAgent” change to what you want.

Do you want to block multiple UserAgents? Use this:

if ($http_user_agent ~* (BadUserAgentFirst|BadUserAgentSecond|BadUserAgentNext) ) {
    return 404;
}

At last, check nginx configuration and reload it if it’s ok:

sudo nginx -t
sudo service nginx reload
 67   2018  
 77   2018  
 85   2018  
Ранее Ctrl + ↓