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
Wednesday, August 14, 2019
Wednesday, July 17, 2019
NGINX PHP-FPM (FastCGI) 504 Gateway Timeout error on
Increase PHP maximum execution time in /etc/php.ini:
Increase PHP-FPM request terminate timeout in the pool configuration (/etc/php/7.2/fpm/pool.d/www.conf):
Increase Nginx FastCGI read timeout under the http section (/etc/nginx/nginx.conf or /etc/nginx/sites-available/nameofvirtualhost):
Wednesday, July 3, 2019
Screenshot of a website
PhantomJS Installation
Install PhantomJS on Ubuntusudo 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/screenshotCopy rasterize.js in the directory where you want the resulting screenshot to take place.
cd /path/to/screenshot
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.
Tuesday, April 23, 2019
Sort by Color
Reference: https://www.dynatable.com/?perPage=50&queries%5Bsearch%5D=2012
// Our custom sort function
function rgbSort(a, b, attr, direction) {
// Assuming we've created a separate function
// to get the average RGB value from an image.
// (see source for example above for getAverageRGB function)
var aRgb = getAverageRGB(a.img),
bRgb = getAverageRGB(b.img),
aDec = ( aRgb.r << 16 ) + ( aRgb.g << 8 ) + aRgb.b,
bDec = ( bRgb.r << 16 ) + ( bRgb.g << 8 ) + bRgb.b,
comparison = aDec - bDec;
return direction > 0 ? comparison : -comparison;
};
// Wait until images are loaded
$(window).load(function() {
$('#sorting-function-example')
// Add our custom sort function to dynatable
.bind('dynatable:init', function(e, dynatable) {
dynatable.sorts.functions["rgb"] = rgbSort;
})
// Initialize dynatable
.dynatable({
features: {
paginate: false,
search: false,
recordCount: false
},
dataset: {
// When we sort on the color column,
// use our custom sort added above.
sortTypes: {
color: 'rgbSort'
}
},
readers: {
color: function(cell, record) {
var $cell = $(cell);
// Store the average RGB image color value
// as a decimal in "dec" attribute.
record['img'] = $cell.find('img').get(0);
// Return the HTML of the cell to be stored
// as the "color" attribute.
return $cell.html();
}
}
});
})