30 months in IT industry 30 lessons learnt

30 months in IT industry 30 lessons learnt

It’s been quite a time when I started working and since then learning something new everyday has became a fact of my life and that’s excites me very much. My passion & love towards learning and exploring new things in IT industry left not an iota of doubt in my mind to choose the largest industry in the world, IT Industry, as my career. Here are some lessons I learnt from my journey of ups and downs, happiness, parties, frustration, tension, pressure and of course FUN.

  1. Knowledge is POWER.
  2. Gain knowledge as much as you can in each and every field.
  3. Never give-up.
  4. Learn to “adjust”.
  5. Keep learning new things.
  6. Keep trying new things.
  7. Learn to perform under pressure.
  8. Grow individually, because if you grow your organization also grow with you.
  9. Do smart work.
  10. Learn to GOOGLE.
  11. Asking for HELP from others must be your last option.
  12. Celebrate your success.
  13. Everyday is a new day, things will change.
  14. Current time will pass away whether it’s good or bad for you.
  15. Grow your network.
  16. Help Help HELP others as much as you can.
  17. Learn to put your ideas & thoughts in front of others.
  18. Learn to manage time.
  19. Learn to help yourself.
  20. Productivity is the only thing that matters.
  21. Versatile knowledge matters.
  22. Expand your knowledge horizontally then vertically.
  23. Learn to convince others.
  24. Learn to appreciate others.
  25. Be a multi-tasker.
  26. Be a good person first.
  27. Keep smiling.
  28. Motivate others.
  29. Make your life goals bigger & clear.
  30. Respect juniors and seniors.

This is just a sneak peek of my career, hope my experience will come handy in your career boost up.

Web scraping using PHP

web-scraping-using-php

Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites.
Source Wikipedia

In very simple words, scraping is extracting data from web page by processing HTML and it is extremely powerful. It is used for various purposes such as analyzing web pages, data aggregation from multiple sources, researching trends and many more.

Web scraping using php

Before starting scraping with php one should have basic knowledge of domdocument and curl.
Let’s being with an example, for website wiredskill.com, it’s a tech news aggregator, we have to do as follows.

  • get title and title length
  • get meta description
  • get all h1 tags
  • get all links from the page

Steps to follow

  • get page content using curl
  • load content in dom document
  • if title exists, get title and it’s length
  • if meta description exits, get meta description
  • get h1 tags and links

All in all, web scraping with php is very easy, so do scraping just for fun because it breaches most of the website policies. Therefore, i really recommend to use it wisely after reading all terms and conditions of the website you are targeting to collect data.

This article is just to give knowledge about scraping, we are not responsible for any harm caused by using above script to any website by anyone.

Mongodb CRUD operations using PHP

mongodb-crud-operations-using-php What is MongoDb?

MongoDB is an open source document oriented nosql database. It is powerful, extremely fast, flexible and highly scalable database. It stores data in the form of JSON like documents BSON(Binary JSON).

Basics of Mongodb

Collection :  In mongo database, data is stored in Collections. These are equivalent to tables in relational database.

Document : Document represent a record in MongoDB collection. We can store integer, string, array, objects and many more type of data as a document in collection.

Schemaless: Mongo has no schema for storing document, we can store any type of data in any cell of a row.

To install mongodb follow this article¬† “How to install mongodb” and install andy GUI tool like MongoVue or Robomongo for better understanding.

Mongodb CRUD operations using PHP

Create records

Single Insert
Consider a scenario where we want to insert user details in “user_details” collection in “users” database.

That’s it, we have inserted a new record and i think you didn’t noticed one thing and that is “we don’t have to create any database or table(collection) or schema in order to create record in mongo“.

mongo-insert-using-php

Now, if you are dealing with a single database then specify database as follows.

Last insert id can be obtained using following syntax, remember that mongo create a default unique and indexed id as _id and it’s an object not string. Check the image at the end.

Bulk Insert
Consider a scenario where we want to insert multiple records at once, then we write it as follows.

Above batch insert shows that you can insert any data type in any field.
In first case, we entered age as string instead of integer (as inserted before).
In second case, we entered a new field has_job and also remove age.
In third case, we entered a multi dimensional array and added a new field salary.

Above example shows that mongo is schemaless.

Applying Indexes
Index is applied on a collection using following query

 

Reading records
Consider a scenario where we want to read above records on the basis of various conditions, we will discuss each aspect one by one.

find function is used to fetch data, it returns a cursor to the data. “hasNext()” ensures that whether any data found or not. After that we have to iterate over cursor to get results, for this “getNext()” function is used.

To count number of results which is obtained from find query writes as follows

Find results with some specific conditions

Updating records

Let’s update some of the user details which we have entered above.

Here ‘multiple’ is used to updated all results with matching criteria, by default mongo will update only one result if we doesn’t pass third parameter in above query.

In the below image you can see data after updating records, in first case skills is an array and in second case it’s an object.

mongo-array-object

Below image shows when mongo is successfully connected then it shows connected as 1, second section shows last insert id and third section shows if update is successful then nModified and n is equal to number of rows affected.

mongo-connection-update

Deleting records

Deleting records is the easiest of all, it is done using following query

Always remember, delete by default works on all records and update works on single record.

That’s all in “Mongodb crud operations using php”.Do comment and subscribe for further updates.