How to block CuteStat from crawling your website

CuteStat shows traffic statistics, but it is bad for your website! It steals your page title and thus also your position on Google searches! To block CuteStat from crawling your website, add this on robots.txt: User-agent: * Allow: /   User-agent: CuteStat Disallow: /User-agent: * Allow: / User-agent: CuteStat Disallow: / In case your website […]

How to Test Robots.txt via Google Search Console

First register your website on Google Search Console: https://search.google.com/search-console/about Then browse to this Robots Testing Tool: https://www.google.com/webmasters/tools/robots-testing-tool Select the property (website) and test your Robots.txt. You can test if a web page is blocked by Googlebot.

PHP Generate Secure Random Passwords

This simple PHP function can generate secure random passwords: function generate_strong_password($length = 15, $symbols = array("!", "#", "=", "@", "+", "(")) { $characters = ‘0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;   $charactersLength = strlen($characters);   $randomString = ”;   // Generate the random alphanumeric string for ($i = 0; $i < $length; $i++) $randomString .= $characters[random_int(0, $charactersLength – 1)];   […]

Google Cloud SQL and Public IP Address Security

When you create a SQL cloud instance and you use a public IP address (external IP) on the SQL instance, make sure that your Compute Engine instances that will connect to the public IP of the SQL instance will have a static IP address and not temporary, else if the IP address is temporary it […]

How to use Highlight.js to highlight code

Using Highlight.js to highlight code is simple: First include this inside the HEAD tag of the HTML page: <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.14.2/highlight.min.js"></script> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.14.2/styles/darcula.min.css" /> <script>hljs.initHighlightingOnLoad();</script><script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.14.2/highlight.min.js"></script> <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.14.2/styles/darcula.min.css" /> <script>hljs.initHighlightingOnLoad();</script> Then you can use it like this: <code class="json"> {name: "John", age: 31, city: "New York"} </code><code class="json"> {name: "John", age: 31, city: "New […]

Nginx HTTP to HTTPS and non-www to www behind Google Load Balancer

First create two forwarding rules on Google Load Balancer (frontend): – One for HTTPS (port 443) traffic – One for HTTP (port 80) traffic Then make sure both rules use the same static IP address. Now on the Compute Engine backend, edit the Nginx config file: server { listen 80; server_name localhost; access_log /var/www/nginx/logs/access.log main; […]

Quota ‘IN_USE_ADDRESSES’ exceeded. Limit: 8.0 in region

If you get this error message when you try to create a new Compute Engine instance: Quota ‘IN_USE_ADDRESSES’ exceeded. Limit: 8.0 in region…Quota ‘IN_USE_ADDRESSES’ exceeded. Limit: 8.0 in region… Then it looks like you reached the quota of IP addresses in use. To solve this, you need to ask to modify the quota of: This […]

Only allow Google Load Balancer traffic (Firewall Rules)

For security reasons you should only allow incoming traffic from Google Load Balancer on your backend instances. To do so, when making a GCE firewall rule, just set the Source IP ranges to these GCE IPv4 ranges: 130.211.0.0/22 35.191.0.0/16130.211.0.0/22 35.191.0.0/16 Read more here: Google Cloud Load Balancer Firewall Rules Tuning NGINX behind Google Cloud Platform […]

Lost connection during Debian apt-get upgrade

If you lost the SSH connection on Debian while apt-get upgrade: 1) Re-login to your SSH server 2) Find the running instance of apt-get upgrade: ps aux | grep -E ‘release|upgrade|apt’ps aux | grep -E ‘release|upgrade|apt’ 3) Then kill it with kill PID 4) Type “dpkg –configure -a” to recover the apt-get upgrade 5) Done!

Bootstrap 3 Navbar with Logo Image

The correct way to use a logo image on the Navbar on Bootstrap 3 is: <a href="#" class="navbar-left"><img src="/path/to/image.png"></a><a href="#" class="navbar-left"><img src="/path/to/image.png"></a> Do not use class=”navbar-brand” in A HREF because it adds text-like styles. Reference: https://stackoverflow.com/a/26333342 If the logo image is too on top, just add this code in the .CSS file: .navbar-default .navbar-left img […]