Tuesday, 29 January 2019

Great Example of passion about programming

Who is a great example of a very passionate software engineer?

I’m sure a lot of you already know what this Dutch legend is famous for.
In case you don’t - he is the creator of Python.


He now works at Dropbox. He started working there under the condition that he would work simply as a software engineernot a lead or even a manager.
In his own words:


“I think it was because I enjoy doing actual engineering work, and I don’t enjoy as much the formal aspect of management. In the past, I was thrown into such a role for a small team, and it never really worked out. I never really felt comfortable in that type of role. I was always much more comfortable just writing code. Over time, that has included technical leadership, but I like to be part of the work and not just tell people what to do or how to do it.”

Reference: a Quora Answer 

Few must link visits to prove that humanity still exists


1) Link 1

Useful links for Software Developers/Database Administrators


More links will be added soon...

Tuesday, 4 December 2018

PHP: array_key_exists() vs isset()

Hello All,

We are talking about an issue which comes to PHP developers almost every day.

Say, we have an array:

$students = [
111 => ['id' => 111, 'name' = 'Philip'],
112 => ['id' => 112, 'name' = 'James'],
113 => ['id' => 113, 'name' = 'Stephen'],
....
];

Say this array has 100000 (one lack) rows.

And we are asked to loop over them and display names or other information.

What we will do it, we will loop over the array and print the records.

Fine up to here.

Second situation:

We need to check whether id 9989 is present in array.

How will you find it?

Way 1:


$studentId = 9899;
if (array_key_exists($studentId, $students)) {
 // Code here
}

Way 2:

Set each student's array's key to its id like: 

111 => ['id' => 111, 'name' = 'Philip'],

Now find it with isset()

$studentId = 9899;
if (isset($students[$studentId])) {
 // Code here
}

Way 2 is much faster than way 1 as it is using in built language construct.

And through Way 1, we are traversing through whole array, where as through Way 2, we are just checking if an index is set.

Friday, 27 July 2018

PHP Tips and Tricks

Use short cut operators for adding/subtracting values from variables.
1) += operator.
Consider following:

$a = 10;
$a = $a + 3;
// $a is 13 now.

We can replace the second statement by:

$a += 3; // Add 3 to $a

2) -= operator.
Consider following:

$a = 10;
$a = $a - 3;
// $a is 7 now.

We can replace the second statement by:

$a -= 3; // Subtract 3 to $a

3) Say if you are assigning a variable to some value if some condition is met. Also, the if condition has another variable set.

Just look at the following example:

if ($condition == TRUE) {
  $a = 7;
  $b = 9;
}
else {
  $a = 11;
}

We can skip the else structure like following:

$a = 11;
if ($condition == TRUE) {
  $a = 7;
  $b = 9;
}

In above code, we have reduced 2 lines of code.

Wednesday, 25 July 2018

Ternary Operator in PHP

Ternary operator is a shrtcut operator for if else statement.

Syntax:

$var = (condition) ? if yes, value : if no, value;

For example:
If you have an if else statement like this:

if ($b>5) {
 $a = 3;
}
else {
 $a = 5;
}

The same thing can be wrote with ternary operator in a single line like:


$a = ($b>5) ? 3 : 5;

Thus, we have seen how much lines of codes is reduced.

Tuesday, 29 May 2018

How to change Apache port in Windows

This problem may occur due to apache not getting required port (default is 80).
The port may be being used by other services.
For example: Skype also has default port 80.
Installing Skype and Apache both on same machine will cause conflict and hence Apache will not start.
Either, you change Skype port or change Apache port as described in following steps:
Change the ports of Apache and it will work for you. Go to httpd.conf
How to change port for Apache:
Search for:

ServerName localhost:80

Change it to:

ServerName localhost:81

Also Search For:

Listen 80

Change it to:

Listen 81

If you have created any virtual hosts, change the ports there also. Then restart your apache.

Reference: https://stackoverflow.com/a/18306621/1841760

Parenting tips to inculcate learning habits in your kid

Parenting tips to inculcate learning habits in your kid Tip #1) Children do not learn things, they emitate. So, try to do things by yours...