How to stop a PHP Script from terminating abruptly?

One can schedule PHP Scripts to run on a server using a Cron job but that does not mean it is going to run successfully. With the fact that  you may have tested the script multiple times with no run time errors being reported. Why would you think that there are uncertainties in this aspect?

PHP as you all know is a server side scripting language which is deemed to run on a server without Interruption. But if the script is running on a server that is  part of a shared hosting plan, restrictions are put in place to prevent a script from running indefinitely. This is done to prevent one tenant from consuming all the resources. And similarly if you use a 3rd party server to schedule/run your script, it would have similar rules on the table. If a script takes more than 30 seconds to run than there is a timeout and it is put on hold.

There are cases where if an end user runs a PHP Script on the browser and closes the tab/window, it would stop executing  because there has been a disconnect from the client side. As a developer we wouldn’t want this to happen. The script should run irrespective of the client’s activity status or the type of Server hosting plan that you have.

Fortunately there is an easy way to fix this! PHP has a one line code that helps in resolving this Issue. The code literally Ignores the Client’s Activity Status.

ignore_user_abort(true);

 

Ignore_user_abort accepts a boolean parameter. If set to true it would Ignore user action. So even if the user disconnects, the script would continue to run until it terminates on it’s own!

Sharing Screenshots using Snaggy

Screenshots are a great way to explain or describe something. It can also be used by IT Professionals to diagnose an Issue that you are facing. They might request you to take a screenshot of the error message that you are getting and share it with them. Most of the time conversations between IT Support take place over the chat. This facilitates a dynamic and Instantaneous form of communication.

Chat as a medium as described above is a good way to deal with customers over Issues that they are facing. In order to share a screenshot, you would have to attach it over chat. But there are still some chatting applications out there that don’t support attachments. Then how would you share a screenshot?

This can be done by using an Online Tool called SnaggySnaggy is very simple and Intuitive. It helps you take a screenshot and it then generates a URL and all you have to do from there is to share the URL with the concerned person.

Here are the Instructions on how would you do this on a Mac. Windows users would get their own set of Instructions by visiting the Snaggy website.

Screen Shot 2018-03-30 at 8.58.09 PM.png

How to get back the old view in Outlook?

Office 365 Users would have experienced a change in the layout of the way emails are listed in their Inbox. Previously the Inbox had two Categories All and Unread. But recently they made a change to declutter the Inbox. Mails that Outlook deems as Important or personalized emails come under the Focussed Category. And Mails that are related to promotions or subscriptions come under the Other Category.

Outlook-1

There might be some of you who have not embraced this new change with the feeling that they might miss out on emails. Outlook would not send you desktop notifications on emails that belong to the Other Category. They would only send notifications to the emails that come to the Focussed Category. Fortunately there is a way to go back to the old view. Here is how to do it!

The Steps

  1. Activate the View Tab
  2. Click on “Show Focussed Inbox”. Outlook-2

 

And that is it! Now you would notice that the layout has changed to All/Unread 🙂

Outlook-3

 

How to check whether the current year is a leap year in PHP?

A leap year is a year that has 366 days that Includes an extra day in February. It occurs once every 4 years with the next leap year occurring in 2020. You would think that finding a leap year would Involve some complex calculation. But, in PHP it is just a single line of code that determines whether the current year is a Leap Year or not.

It uses the date library function.

date("L");

This returns a boolean value. 1 being that the current year is a leap year and 0 if it is not.

 

How to cut and paste on a Mac?

Windows users would probably know the hotkeys to cut and paste files or content. In Windows to cut and paste files one would use Ctrl-X  to cut and Ctrl-V to paste.  One would think that to you could use the same hotkeys for Mac but unfortunately that is not the case. There is a slight difference which I will explain below.

Let’s take an example-

I have a folder called Test1 that has one file called Test.

Screen Shot 2018-03-27 at 11.50.29 PM.png

And I have another folder called Test2 that is empty.

Screen Shot 2018-03-27 at 11.51.37 PM.png

Now, I want to cut and paste the file from Test1 to Test2. The End Result should be that Test1 is Empty and Test2 has one file called Test. How can we achieve this on a Mac?

In Mac apart from the Ctrl key, we have another key called Command. And in most of the cases Command is used over Ctrl. In this case we would be using Command rather than Ctrl.

According to the procedures, the first step is to copy the file using this hotkey

Command-C

So, we would go to the Test1 Folder and copy the file using the above command.

Then we would go to the destination folder and paste the file with this-

Option-Command-V

 

Now, the end result is a Cut and paste effect even though we used a copy statement at the beginning. So, finally you should see one file in the destination folder with the Origin folder being empty.

Screen Shot 2018-03-27 at 11.59.19 PM.png

 

How to search for comments in Excel?

In one of my recent blogs, I talked about how to add comments to Excel . Now that you have added some contents to your spreadsheet, it is Important to know how to search for a specific comment. Given that you have many comments, there may be situations where you need to look for a specific comment and you remember one or two words that could probably be on that comment. In that case, how would one find a comment? Let’s find out-

 

The Steps

  1. On your Spreadsheet, type the keys Ctrl and F.
  2. This would open a Search Window. Now enter the keyword on the search bar and under the “Look in” dropdown select Comments. And then click Find Next. Screen Shot 2018-03-26 at 11.40.11 PM.png

 

Now, in this case this Search would take you to each and every comment that contains the word “banana”.

 

 

How to change the default web browser in your Mac?

As you all know that the default web browser in a Mac is Safari. So, any link that you click would open on Safari. If you want this to open on some other browser you would have to change the default web browser on your Mac.
This is how you would do it-

 

The Steps

  1. Open System Preferences. Screen Shot 2018-03-24 at 9.27.42 PM
  2. Click on General, located on the First row and First Column.
  3. Click on the DropDown in the Default Web Browser section and select the browser that you want.Screen Shot 2018-03-24 at 9.27.52 PM

 

Now any URL in your email or your notes would now open in the browser of your choice. 🙂

How to add a comment in Excel?

Have you faced situations where you look at a formula that has been applied to  certain cells and wondered what the numbers mean or represent? Adding Comments to cells would help the end user viewing an excel spreadsheet get a better understanding of the data.

This is how you would add comments in Excel

  1. Right click on a cell where you need to add a comment.
  2. And Select “Insert Comment“. Screen Shot 2018-03-24 at 9.14.08 PM
  3. You would then see something that looks like a Post-it note where you can add your comments.   Screen Shot 2018-03-24 at 9.18.06 PM
  4. Once you add a comment you will notice a small red triangle in the cell where you added the comment. Screen Shot 2018-03-24 at 9.21.32 PM.png

What’s new in Excel 2016 or Excel for Office 365?

Excel has recently come out with some new features that were released to the end users of Office 365.

Some of the features are as follows

  1. Deselect Cells- How often have you selected some cells in Excel only to realize later that not all the cells that you selected are required? Then the only way to go about this is to start all over again. But this is a thing of the past since Excel now allows you to deselect cells after making a selection. So, In case you have accidentally selected some cells, you could deselect them rather than going back to square one.
  2. Insert 3D Models– Windows 10 users would have noticed a desktop application called Paint 3D. This is where you can create 3D Models. Excel now allows you to Import these models to your spreadsheet in order to better Interpret the Information at hand.
  3. Convert SVG Icons to Shapes-SVG also known as Scalable Vector Graphics is a format for Images where the resolution or the sharpness of an Image is maintained even when it is zoomed or blown up. SVG Images can now be transformed Into shapes for further manipulation.

Excel

How to Embed a Google Map on your Website?

In this day and age saying that a map would be a “good to have” on your website would be an understatement. Maps give Information and credibility to a company. So, it is very Important to have this on the website. Fortunately it is not an arduous task to Implement it. Here are the steps-

The Steps

  1. Open Google Maps
  2. Enter the Location of the place that you would like to show on the website.
  3. Click Share GMaps
  4. Activate the “Embed Map” Tab. GMaps-2
  5. Copy the iframe code. This code can be pasted on the body of the HTML File.