Monday 26 November 2018

How to Clear Error & Access Logs on Ubuntu 16.04 Apache Server

Here is an example of the terminal commands to clear error logs and access logs. Remember to update the file paths to the location of your error/access log/s.

sudo bash -c ‘echo > /var/www/html/logs/error.log’sudo bash -c ‘echo > /var/www/html/logs/access.log’

Original Article Posted On: https://andycorby.com/clear-error-access-logs-ubuntu-16-04/

Some Programming Best Practices for Productivity

Here are some of my thoughts on programming best practices to improve productivity.

YAGNI: “You Ain’t Gonna Need It”. Don’t write code that you think you might need in the future but don’t need yet. This is coding for imaginary future use cases and the code could become dead code or need rewriting because the future use case could turn out to work differently from how you imagined it.

Comments & Console Logs: When comments are used they should be used to explain why the code is there, not what it’s doing as that can be read in the code itself. Blocks of commented code shouldn’t exist in productions releases. This is also true for testing console log statements which should not make it to production releases.

Testing: Test all changes. Only if there is a very good reason should code be left untested. Lack of time is not a good reason and can end up costing more time. Possible good reasons include: genuinely un-testable (in any meaningful way), impossible to hit in practice, or covered elsewhere in a test. Code without tests is a liability.

Code is the Enemy: Code can go wrong and it needs maintenance, so try to write less code, delete code, and don’t write code you don’t need.

Write Defensively: Always think about what can go wrong, what will happen on invalid input, and what might fail, this will help you catch many bugs before they happen.

DRY: “Don’t Repeat Yourself”. If the same code is being repeated multiple times consider putting it in a reusable function. This is more important in production files and not as important in test files, keeping code and what could go wrong in the production environment to a minimum.

Correct VS Speed: Make code correct first and fast second. The top priority is to write code that works and has been confirmed with test. The second priority is the performance and speed of the code (within reason, provided it is not excessively slow code which will cause issues).

Standard Format: It is good to have a standard format (use of indentation, spaces, blank lines, comments) all developers on a project work to, in order to help improve fast readability and help reduce development time.

Original Article Posted On: https://andycorby.com/some-programming-best-practices-for-productivity/

The Great Firewall of China – SSL Certificates

When Search Engine Optimising a Chinese website for the main Chinese search engine Baidu, there are benefits to having a .cn domain name and having a server located within the Great Firewall of China.

From what I understand the Chinese government censors web pages by intercepting the connection between a server and the end user. If a web page does not pass their censorship then the page could be edited or not displayed to the user.

Whilst having an SSL certificate protects users data it can stop the Chinese government from censoring individual web pages so if a page does not pass censorship then a whole website may be blocked. Therefore, you may want to consider your SSL set up carefully and whether you will force HTTPS when setting up a server within the Great Firewall of China.

Useful Article: https://jpgamboa.com/ssl-usage-china/

Original Article Posted On: https://andycorby.com/the-great-firewall-of-china-ssl-certificates/

Free Website Optimisation Tools

Here is a list of some free useful Google website optimisation/analysis tools:




Here are some further free useful website optimisation/analysis tools:




Original Article Posted On: https://andycorby.com/free-website-optimisation-tools/

How to Set Time Zone on Ubuntu 16.04 Apache Server

Here we’ll cover how to set the default time zone on your Ubuntu 16.04 Apache Server.

First, open your php.ini file (found within the /etc/ directory) in a plain text editor, your file path could vary but here are a couple of example of possible file paths:

/etc/php/7.0/apache2/php.ini/etc/php.ini

Find the following line in the php.ini file. If there’s a semi-colon at the start of this line then remove the semi-colon to uncomment this.

date.timezone =

Set date.timezone equal to your continent and main city, a list of all available time zones can be found at http://php.net/manual/en/timezones.php

For Example:

date.timezone = Europe/London

Save your php.ini file and then restart Apache using the following command in terminal:

service apache2 restart

Original Article Posted On: https://andycorby.com/set-time-zone-ubuntu-16-04-apache-server/

How to Install a Free LetsEncrypt SSL Certificate on Ubuntu 16.04 Apache Server

Here are the terminal commands to set up a free LetsEncrypt SSL certificate on Ubuntu 16.04 Apache server.

First run these commands in terminal:

sudo apt-get updatesudo apt-get install software-properties-commonsudo add-apt-repository ppa:certbot/certbotsudo apt-get updatesudo apt-get install python-certbot-apache

Now you will be able to install multiple free LetsEncrypt SSL certificates by running the following terminal command for each of the domains on your server, replacing example.com with the domain you want an SSL certificate for.

sudo certbot –apache -d example.com -d www.example.com

If you want to force HTTPS then don’t forgot to update the .htaccess file for each website your want to force HTTPS on.

It’s also worth noting that when installing multiple LetsEncrypt SSL certificates on a server you may need to edit the following file manually to ensure each of the domains is included in this file. I’ve found when installing multiple LetsEncrypt SSL certificates on the same server it can overwrite the first entry in this file.

/etc/apache2/sites-available/000-default-le-ssl.config

Useful Resources

  • https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-16-04
  • https://certbot.eff.org/all-instructions/#ubuntu-16-04-xenial-apache

How to Install a brought SSL Certificate on Ubuntu 16.04 Apache Server

Here are the terminal commands and steps to install a brought SSL Certificate on Ubuntu 16.04 Apache server (not LetsEncrypt).

sudo mkdir /etc/apache2/ssl
sudo mkdir /etc/apache2/ssl/private
sudo chmod 755 /etc/apache2/ssl
sudo chmod 710 /etc/apache2/ssl/private
sudo chown -R root:root /etc/apache2/ssl/
sudo chown -R root:ssl-cert /etc/apache2/ssl/private/

Now, place your SSL public certificate(s) in /etc/apache2/ssl and your SSL private key(s) in /etc/apache2/ssl/private

sudo chmod 644 /etc/apache2/ssl/*.crtsudo chmod 640 /etc/apache2/ssl/private/*.key

In /etc/apache2/sites-available update the file paths for SSLCertificateFile, SSLCertificateKeyFile, and SSLCertificateChainFile.

sudo a2enmod sslservice apache2 restart

Useful Resources:

  • https://serverfault.com/questions/259302/best-location-for-ssl-certificate-and-private-keys-on-ubuntu
  • https://www.digicert.com/csr-ssl-installation/ubuntu-server-with-apache2-openssl.htm

Vaping – Aspire Nautilus X Tank – Helpful Tips To Use Your Tank

Here are a few helpful tips when using your Aspire Nautilus X Tank:

Pressure build up in the tank can make it hard to toke at times (typically not long after having a full tank). Simple fix, just loosen the tank lid to release the pressure and you’ll see bubbles come out the coil, re-tighten the lid and you’re good to go.

The tank spitting juice can be caused by excess liquid in the coil. Another simple fix, cover the tip and vents with a tissue and flick your wrist, you should see juice on the tissue, repeat until no juice comes out. If you still have a problem then hold the button on the vape down without toking (approx 1 second). You should hear the sound change as the excess juice burns off and your good to go.

Preparing Coils (aka priming) – before installing a new coil, drip a few drops on both areas of exposed cotton wool, install, fill up the tank, replace the lid. Now open the vent and with the device off (do not push the button), draw air through the vape, repeat until you can hear a slightly bubbling of vapour in the coil. Ideally now leave to stand for a few minutes. Turn on the device, set the wattage lower than advised (10W is good). Start vaping, if there’s a burning or cotton wool taste then you haven’t drawn the juice through enough. When you’re happy the liquid’s coming though enough then work up the Wattage to your desired level, taking a few tokes at each increment. The ideal Wattage for each liquid depends on the liquid and your preferences, so start the wattage off low (10W) and work up until you find the sweet spot for that juice that you like the most.

Toking too frequently can make the tank overheat, you’ll get less vapour and an increased chance of burning your coil. If this happens try to allow more time between tokes.

If you experience any other issues with the tank I’d recommend checking the coil first, as it’s the part that’s most likely to have any issue.

Thicker (higher VG) liquids and juices with a high sugar or salt content typically shorten a coils life span, as well as vaping in cold weather. If you use the tank in cold whether I’d recommend using a rubber vape band around the tank to keep it insulated.

To prevent the coil coming out when removing the lid to refill, I’d recommend tightening the coil to the base slightly more than the lid to coil. This doesn’t work if thread wet.

Original Article Posted On: https://andycorby.com/vaping-tips-nautilus-x-tank/

How To Find .edu and .gov Backlinks Using Google Search Operators

Quality backlinks can be great for Search-Engine-Optimisation (SEO). Backlinks from .gov and .edu websites can carry high authority. Here’s how to find .gov and .edu websites where you may be able to post a comment with a backlink to your website.

Type the following into Google replacing “Your Keyword” with a keyword relevant to your business.

For .gov websites:

site:.gov inurl:blog “post a comment” -“comments closed” -“you must be logged in” “Your Keyword”

For .edu websites:

site:.edu inurl:blog “post a comment” -“comments closed” -“you must be logged in” “Your Keyword”

I’d recommend only posting/commenting on relevant content with an appropriate message.

Original Article Posted On: https://andycorby.com/find-edu-and-gov-backlinks/