Debugging Issues with Apache2

By | Apache

Knowing the exact issue is important.


apachectl configtest
journalctl -xe
systemctl status apache2.service
sudo nano /var/log/apache2/error.log
netstat -ltp | grep :80 # To know if a program is occupying port 80

FYI: Apache modules reside in following. Sometimes we have mismatch of module especially after switching php version. If the loaded version is different and available version is different, that causes error too.


/usr/lib/apache2/modules

PHP: function number_format issues and solution

By | PHP

Following is not really an issue but we could run into a trap if we don’t be careful about it. Bottom line is to understand that number_format returns string and when any arithmetic operation is performed to it, we could end up with huge problems.

We can use round but round for 45.20 will give 45.2. Even when we asked for 2 decimals. money_format returns string as well. I guess it will be best to use round for calculations and for displaying numbers use number_format or money_format.


<?php

$a = number_format(100000, 2);
$b = number_format(100000, 2);

$c = $a + $b; // 200

// TODO: FIXME: REMOVE THIS
var_dump($c);

$a = round(100000, 2);
$b = round(100000, 2);

$c = $a + $b; // float(200000)

// TODO: FIXME: REMOVE THIS
var_dump($c);


$c = 45.1261423;
echo money_format('%i', $c); // 45.13


setlocale(LC_MONETARY, 'en_CA');

var_dump(money_format('%i', $c)); // string(13) "CAD200,000.00"

JavaScript Numbers

By | Javascript

What is JavaScript equivalent for number_format in php?


// Lodash to rescue
// Works exactly as we expect. Output is a typeof number.
_.round("10.608", 2); // 10.61

// Following returns the output as string. That's one major down side.
parseFloat("10").toFixed(2); // 10.00
parseFloat("10.60").toFixed(2); // 10.60
parseFloat("10.605").toFixed(2); // 10.61

Laravel 5.2 – Local query scope not working with cron job / scheduler

By | Laravel

I have observed local query scopes do not work with cron job.

To make it work, I simply scaled down. I put the conditions itself rather than using local query scope.

I know it completely defeats the purpose of creating local query scopes in the first place but at least for now it made the cron job run. Let’s hope this issue gets addressed soon. It is really convenient to use local query scopes.

There is one more issue I found with Laravel cron job.

Issues with Laravel cron job (scheduler)

By | Laravel

Laravel is great at almost everything but there are few areas where it lacks it’s awesomeness.

Problem with cron job (Laravel – 5.2)

I noticed some of the cron jobs were not running. You can use following command to check and run the cron job execution.


php artisan schedule:run
Turns out when the cron has withoutOverlapping method chained. It creates a file in the storage/framework folder with the name of schedule-***. 

It appers the existence of this file is used to check whether the cron job is running or not. When the cron job fails for whatever reason the file is not deleted. Since, the file exists the system thinks the cron job is still running and it is not done yet.

This prevents the cron job execution.

For now the solution is to delete the schedule-*** file.

Note: I would also want to add one of my observations: php artisan schedule:run will not show the task(s), if the job only runs on specific day (e.g. everyFriday()) and specific time. The tasks with everyMinute() should run just fine. It makes sense too.

I came across one more issue with Laravel cron job.

What is the ideal slider image size for homepage for various resolutions/breakpoints?

By | CSS, Responsive, Uncategorized

It is essential to use different slider images for desktop and mobiles. Because, the desktop slider image will look very small in terms of length. Any text over slider will have very little space. Hence, for mobile we must use an entirely different image.

Mobile

For mobile I use – 500px x 375px. While writing media queries. You should also consider the landscape resolution (will be discussed soon).

Tablet

The resolution – 960px x 540px seems like a good fit on a tablet.

Desktop

For desktop whatever looks good to your eyes should do it. In one of my recent project, I’ve used – 1900px x 600px