Friday, September 13, 2019

Compare two files


MAKE sure you sort the files first
sort file_unsorted > file1
sort file_unsorted2 > file2
The comm command (short for "common") may be useful comm - compare two sorted files line by line
#find lines only in file1
comm -23 file1 file2 

#find lines only in file2
comm -13 file1 file2 

#find lines common to both files
comm -12 file1 file2 

Wednesday, August 14, 2019

Delegation Domain Name

Let's say you need to redirect a website within your domain to an external host.  Instead of creating a webserver and redirecting the traffic.  In some case such as being on the same domain and wanting to redirect to an external name yet it includes your domain.

example: your domain is example.com.  You want www.example.com yet it is hosted by somewhereelse.com.  somewhereelse.com has a c-name of www.example.com

Solution is to add a delegation under your forward lookup zone.  Add two new name server: resolver1.opendns.com and resolver2.opendns.com


Ubuntu Flush DNS

sudo systemd-resolve --flush-caches
sudo systemd-resolve --statistics

Wednesday, July 17, 2019

NGINX PHP-FPM (FastCGI) 504 Gateway Timeout error on


Increase PHP maximum execution time in /etc/php.ini:
  • max_execution_time = 300

  • Increase PHP-FPM request terminate timeout in the pool configuration (/etc/php/7.2/fpm/pool.d/www.conf): 
  • request_terminate_timeout = 300

  • Increase Nginx FastCGI read timeout  under the http section (/etc/nginx/nginx.conf or /etc/nginx/sites-available/nameofvirtualhost): 
  • fastcgi_read_timeout 300;
  • Wednesday, July 3, 2019

    Screenshot of a website



    PhantomJS Installation

    Install PhantomJS on Ubuntu
    sudo apt-get update
    sudo apt-get install build-essential chrpath libssl-dev libxft-dev
    sudo apt-get install libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev
    wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
    tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/
    sudo ln -sf /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin
    phantomjs --version
    2.1.1

    mkdir /path/to/screenshot
    cd /path/to/screenshot
    Copy rasterize.js in the directory where you want the resulting screenshot to take place.
    wget https://raw.githubusercontent.com/ariya/phantomjs/master/examples/rasterize.js
    phantomjs --debug=yes --ignore-ssl-errors=true --ssl-protocol=any --web-security=true rasterize.js https://enews.ssis.edu.vn enews.png "400px*300px" .25

    The last variable is the zoom factor of the website.  In this case .25 means 25% of the website in a 400px by 300px thumbnail.