Posts

Showing posts from 2019

How to Lead - All You Need to Know to be A Good Leader

Image
There is no specific field/domain (development, marketing, management, etc.) to become a leader and you don't need to wait for an opportunity for the same. Leadership can be observed in any field/domain in any small or big tasks. But there are few observations of a good leader. Observations on Leadership 1. No Single type of personality for leadership : The is not any particular type of person who is only able to lead. Anyone can become a good leader no matter what kind of personality you have. You do not need to look like or copy anyone great leader, just be yourself. 2. Three Fundamental Attributes :       -  Great leader thinks and communicate clearly : Simple and clear communication actually needs your thought process and time. Take some spare time, write down your thoughts then think about how to make them more simple and clear to communicate.       It always pays you back to communicate clearly.       -  Good Judge...

How to Show Cookie Policy Consent or GDPR Popup in Laravel using Cookie.

Cookie in Laravel You can use the cookie in Laravel using the Helper method ` cookie() ` or method available with Request/Response Object or `Cookie` facade. $request->cookie('name'); OR use Illuminate\Support\Facades\Cookie; Cookie::get('name'); To get more clarity on how to use the cookie in Laravel with an example to show cookie consent popup on your Laravel website and hide/remove it once you accept the policy. Cookie Policy Consent Popup in Laravel First, create and a Cookie Consent popup as notification to the footer section of your Laravel main blade template file.  <div class="cookies-block">         <h5>This website uses cookies</h5>         <p>We use cookies to improve your experience and deliver personalised content. By using this website, you agree to our <a href="javascript:void()">Cookie Policy</a>.</p>         ...

How to Write Redirect Rules for HTTP to HTTPS in Apache using .htacess

HTTP vs HTTPS HTTP (HyperText Transfer Protocol) is the most basic and known protocol (a standard set of rules) used to transfer data from a web server to a browser. It allows communication between different systems. HTTPS is HTTP with encryption i.e it uses encryption (TLS/SSL) to make HTTP requests more secure while transferring the data from a web server to a browser or vice-versa.  So there are benefits of using HTTPS for your website: 1. It makes your website more secure against data theft. 2. It also improves your SEO rank. So now let's learn how we can direct a website from HTTP to HTTPS. First, make sure you have generated and integrated SSL certificate for your website and the Rewrite module is enabled on your hosting server. so that your website can work on HTTPS without any trouble. After applying the SSL certificate our website can be accessed via HTTP or HTTPS. But per above after knowing the benefits of HTTPS we need redirect HTTP to HTTPS. ...

Ways to Pass Parameters to Laravel job.

There are 2 ways to pass parameters to a dispatching job in Laravel. First is simply call dispatch() or dispatchNow() as per requirement on your Job class like calling a static method on a class: YourJob::dispatch(argument1, argument2, argument3); Second is simply pass arguments while creating an instance/object of Job class then pass the object to dispatch method(always available in the controller) like: $this->dispatchNow(new YourJob(argument1, argument2, argument3)); The arguments will be available in the constructor, can you assign them to class local variable properties and use anywhere in Job class. Let consider below example job: <?php namespace App\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; class Testjob imple...

Important things every developer need to know about Database Indexing

Assuming you know the basics of Database and know the definition of indexes used in DB, here are some important things about Database indexes about which every good developer must aware of: DB Indexing is used to read data faster, but it makes writing slower. Indexes use in-memory data structures. Indexes use B-Tree (Balanced Tree) data structure to store data and use Binary search for reading/searching. It always saves corresponding DB internal row-id (not table PK) with every indexed node in the B-tree It is not good to add an index to each column of a table. If you have applied index on certain column but in query use any function on an indexed column, the index will not help at all. You can create a combined index on multiple columns. Order matters as per query need. To understand the use of indexes or to know if the query is actually taking the benefit of your index on your column use Explain. Explain give you the execution plan of the query. Explain give you info abou...

Ubuntu Terminal - Commands for User Groups, Directory, Permissions and Ownership

When you are working on Ubuntu/Linux OS, some important command given below can help you in managing Users groups and directories. 1. Check user-groups, a user account belongs to: $ groups 2. Add new user-group $ sudo groupadd user-group-name 3. Add user-account to a user-group: $ sudo usermod -a -G examplegroup exampleusername OR $ usermod -a -G group1,group2,group3 exampleusername 4. Change user account’s primary group: $ usermod -g groupname username 5. To change ownership of a folder: $ sudo chown -R www-data:www-data /var/www/ OR $ sudo chown -R $USER:$USER /var/www/example.com/public_html $USER will take account of the current user logged in. 6. Check permissions to specific directory: $ ls -ld /directory/ 7. Link command (creating shortcut): $ sudo ln file1.txt file2.txt or we can also use ln to create symbolic links with the -s option $ sudo ln -s file1.txt file2.txt

Create Virtual host (vhost) in linux - Ubuntu 18.04, 16.04

Virtual Host is a well-known term in web development. Generally, the remote server where we keep your website code/files is called a hosting server. Similarly, when are working on local system with any installed server like Apache or Nginx, it acts as a host. So to access the website on our system with any a custom domain name like 'yourproject.com' instead of something like 'localhost/yourproject', which sometimes create a problem when accessing relative URLs to base URL of the project. So the best way to create virtual host your local system which we work as the remote website works with a domain name. To Create Virtual Hosts(vhost) for apache2 server in Linux/Ubuntu using terminal follow below steps: 1. Copy default site conf file with the name of the your-website name i.e. laravel-demo.com.conf $ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/ laravel-demo .conf 2. Open new conf file into an editor with root permission: ...

Using Virtual Columns in Laravel - Accessors and Appends

What are virtual columns?  While developing any web application sometimes we need virtual columns - columns don't actually exist in our DB table, but we drive them from other columns. Why we need them? For example, generally, we use first_name and last_name  in the  users table. But sometimes we also need user's complete name i.e. full_name . There is no benefit of saving full_name in user table if we have already first_name and last_name in the table OR even if we have full_name  as a column in our table then there is no benefit of saving first_name and last_name in the table. So in a scenario like this, we prefer to use the virtual column. Using Virtual Columns in Laravel Considering the first case, in Laravel to get virtual column i.e.  full_name  from the users table will have Accessors. Accessors are methods defined automatically called by Eloquent when select is called on that particular column. Let take an example here: To get full_...

Laravel validation rule 'Exists' with secret feature.

In this post, I wish to share one secret feature of laravel validation rule 'Exists'. If you have worked with laravel and familiar with laravel validation, you must know what does 'Exists' rule checks. If not let me give here a brief about this. In simple words,  'Exists' rule check if a record exists in the given database table with column value matching with the provided input value. Format: 'exists:table,column' So this is what as mentioned in laravel documentation too. So looking at the format we understand that this rule is to validate given input value by check if any records exist or not for that particular input value matching with the given column values of the table. Let's take an example. 'booking_id' => 'exists:bookings,id' Here we are validating provided booking_id with exists, if records exist in bookings table matching the column id (in most of the cases but can use any column as per your requirement.) ...

What is an icalender or .ics file?

Image
An icalender or ics file is a simple text file with some pre-defined format and tags saved with extension .ics. It is usually used for inviting someone to an event via email to which user can respond to actual sender very easily or can add an event in his/her calendar i.e. Google Calendar, Apple Calendar etc. The file format is specified in a proposed internet standard RFC 5545  . A Simple Example ICS file ICS file has a pre-defined format and Tags like if we talk about HTML page. BEGIN:VCALENDAR VERSION:2.0 PRODID:-//hacksw/handcal//NONSGML v1.0//EN CALSCALE:GREGORIAN METHOD:REQUEST BEGIN:VEVENT DESCRIPTION:Meeting of board members DTSTART:20190206T090828Z DTEND:20190206T093828Z SUMMARY:Meeting LOCATION:6116 Breitenberg Radial Vanessaview\, AK 79372-4114\, West Vincenzo\, 86360-8926 URL:http://example.com DTSTAMP:20190206T090828Z UID:5c5aa40c3f305 ORGANIZER;CN=Joelle:MAILTO:ohackett@example.org END:VEVENT END:VCALENDAR ...

This is my First Post.

Today i am starting to write this blog to share my personal experience, knowledge or skills i learned in the life.