Culture

Culture is esoteric to people who live or belong to it. It’s a representation of how they live, they dress, celebrate festivals, engage with people and their cuisine. Food is not the best way to get a deep understanding of a culture since culture is an amalgamation of different components that coherently come together to form what we know as culture.

Food is a source of energy and needed by mankind to survive and we cannot live without food. It’s needed by people all across the world. They may have different ways of obtaining and preparing their food. However, just by understanding how the food is obtained or prepared doesn’t make one understand their culture. To deeply understand culture, one needs to understand their history, clothing, language, films and religion. It’s a composition of all these entities that embodies a human being that is ingrained to their culture.

Getting an understanding of festivals would help one know about how people come together and celebrate. There is a festival in the South of India, celebrated in the state of Kerala known as Onam. It’s celebrated over a period of 10 days marked by flower arrangement on the floors of their houses in different patterns and sizes that progressively increases in size until the final day. The final day is marked by a grand lunch with friends and family. Festivals are one of the many components that can be used to understand culture.

Clothing is another component in the myriad of components that form a culture. It’s analogous to a cake that has many cake pieces. The cake is the culture formed by all these cake pieces. Clothing is one piece of the cake. Traditionally, people in the state of Kerala used to wear a garment called the mundu that is wrapped around the waist and they wear a shirt on top. Many people still wear it day to day however the trend is shifting to the westernized form of clothing. People do wear their traditional attire during festivals and weddings.

In conclusion, to deeply understand culture, one would need to understand all the components that form a culture and it’s not just food.

How to reset Auto Increment to a specific value in MySQL?

Once a column is set to Auto Increment the value would Increment by one for every record added. Therefore, the column value for each record would be unique and hence it could be set as a primary key. There may be times when you would want it to Increment from a specific value. This is how it can be done-

ALTER TABLE table_name AUTO_INCREMENT=1001;

 

In the above example, Auto Increment would begin from 1001 rather than 0.

 

PHP MYSQL Error Message-mysql_fetch_row expects parameter 1 to be resource-

mysql_1

This is an error that one faces when they use mysql and mysqli Interchangeably. Functions that begin with “mysql” are deprecated and no longer supported in the latest versions of PHP. So, one should either use mysql throughout the program or mysqli, mix and match doesn’t work. Mix and match might work in the grocery store that might help you to get sale prices but unfortunately it doesn’t work here! 😀

 

How to fetch the last ID from a MySQL Table and save it in a PHP Variable

When you are Involved in comparing and updating two different tables there may be times when you would need the last ID of a table so that it can be used in another table provided the ID is a primary key set to Auto Increment.

The way you would go about this is to use the max keyword to get the last ID of a table and then use the mysql_fetch_row function to fetch a row of data from the result handle. This value is then saved in a PHP Variable that can be later used for further manipulation. The overall code would appear to be something like this-

//Database Connection
$db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName);



//Get the Last ID of a table. The column name is "SNo"
$last_id = mysqli_query($db,"SELECT max(SNo) FROM Test4_HarvestData");




if (!$last_id) {

    die('Could not query:' . mysql_error());

}



//The Last ID saved in a PHP Variable
$row_sno= mysqli_fetch_row($last_id);


echo "<br>The Last ID is : ".$row_sno[0];

 

 

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!

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 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.

How to convert to a specific date format in PHP?

Date is something which could be represented or described in many different ways. For Instance the date today could be represented in the following ways-

20th March 2018

03/20/18

20/03/18

2018/03/20

And so on

So, it is Important to know how would one convert from one format to another.

The first thing to do is set a default date format.

date_default_timezone_set('EST');

 

Then if you want the output of the date to be as month/day/year

$date_formatted=date("m/d/Y",strtotime($date));

 

This statement can be modified to the format that you require.

You need to pay attention to the characters that are used to describe the dates, they are case sensitive.

This would give you a detailed explanation on the characters and their description.

 

How to run multiple Web-Applications simultaneously?

The short answer is to use a different port number. For Instance in Angular, the default port number for an application is 4200. If you want to run another application at the same time, you would have to use a different port number. Which brings us to a question-

How to change the port number for an application?

Different frameworks have their own ways to change port numbers. In Angular, one would have to type this command in the terminal in order to change the port number-

ng serve –port port_number

where port_number is the number that you Intend the application to use.

Notice that there are two “dashes” before port

For Example-

If you want the application to use port number 4401, then you would do this-

ng serve –port 4401

 

 

 

What is a Component in Angular?

A Component is a programmable container that holds application and presentation logic. Any element on a web page can be regarded as a component. For Instance a button could be considered as a component.

In Angular, the Entry Level Component is called App Component. A Component normally contains 4 files

app.component.html

app.component.css

app.component.ts

app.component.spec.ts

Screen Shot 2018-03-08 at 4.55.45 PM.png

The Presentation Logic is written in app.component.html, The Application Logic is written in app.component.ts. Code for styling is present in the app.component.css file and the code for testing resides in the app.component.spec.ts file.

I would be discussing this in further detail in my upcoming blogs.