Posts for Snippets

Useful and effective code snippets for Vue, React, JavaScript, Laravel and more..
Deven
Deven wrote

State in React – explained

In React State of a component is an object that holds some information that may change over the lifetime of the component. We should always try to make our state in React as simple as possible and minimize the number of stateful components. Let’s create an user component with message state, State is similar to props, […]

December 30, 2020 in React & Snippets
Deven
Deven wrote

Asynchronous JavaScript – The Beginners Guide

Before you get started with this guide, you should have a fair knowledge of JavaScript fundamentals. At its base, JavaScript is a synchronous programming language. This means it is single-threaded; only one operation can be executed at a time.To truly understand why async/await is important, we have to take a deep dive into JavaScript’s core […]

December 7, 2020 in Javascript & Snippets

Centering Things in CSS Using Flexbox

Flexbox makes it easier to design a flexible responsive layout structure without using float or positioning. Contents Introduction Horizontal Centering Vertical Centering Horizontal and Vertical Centering using Flexbox Conclusion Introduction I just want to talk about how we would currently layout a page using CSS before flexbox in a browser. We typically use different positional […]

September 22, 2020 in Snippets

CSS box-sizing Property – explained

The box-sizing property CSS defines how the width and height of an element are calculated, that is,  should they include padding and borders, or not. Contents Introduction Box-sizing values Without the CSS box-sizing Property With the CSS box-sizing property Box-sizing reset Methods Conclusion Introduction The box-sizing property can make building CSS layouts easier and a […]

September 3, 2020 in CSS & Snippets

Remove First and last Element From Array Javascript

JavaScript has functions that help us manipulate arrays. Contents Remove the First Element From Array Remove the Last Element From Array Consider the following array. Remove the First Element From Array shift() removes the first element of an array and returns the removed element. Output Remove the Last Element From Array pop() removes the last […]

August 26, 2020 in Javascript & Snippets

Inline vs inline-block Display in CSS

In this article, we will see the difference between Inline vs. inline-block The display property defines how the components are going to be placed on the web page. Contents Syntax Inline-block Example Inline Example Conclusion Syntax Inline-block Allows setting a width and height on the element. The top and bottom margins/paddings are respected. Does not add a […]

August 26, 2020 in CSS & Snippets

SQL Trigger Example | Triggers in SQL Tutorial

SQL Trigger Special procedures are activated when an insertion, update or deletion occurs in a table or view. SQL Trigger differs from stored procedures in that they are not called directly by the user: when a certain event occurs in the table, they are executed. Benefits: Maintain data integrity: update associated tables. Creates system logs: […]

August 25, 2020 in Snippets & SQL

Convert PHP Object To JSON | PHP Array To JSON

Since JSON is a ubiquitous data format for sharing and storing data, a PHP backend must allow JSON data processing. In this tutorial, we’ll learn about the JSON format and convert PHP Object to JSON. Contents Definitions Array Object Json json_encode Function json_decode Function PHP Array to JSON JSON To PHP Array PHP Object to […]

August 23, 2020 in PHP & Snippets

MySQL Aggregate Functions – SUM,COUNT, MAX, MIN, AVG

In database management, an aggregate function or aggregation function, according to Wikipedia, is a function where the values of multiple rows are grouped to form a single summary value. There are different aggregate functions, such as SUM, COUNT, MAX, MIN, AVG, etc. In this tutorial, we’ll cover the most used aggregate function in detail. Contents […]

August 22, 2020 in MySQL & Snippets
Deven
Deven wrote

How To Convert Python String to Int and Int to String

Sometimes we may need to convert a variable of type String to Integer and from Integer to String. Python provides a built-in method to do this exercise. The methods are int() to convert String to Integer and str() to convert Integer to String. int() methond to convert String to Integer str() method to convert Integer […]

August 21, 2020 in Python & Snippets

How to Use MySQL INSERT INTO SELECT query

In today’s tutorial, we’ll learn how to use the MySQL INSERT INTO SELECT query to insert data into a table where data comes from the result of SELECT query. Contents Before we kick off INSERT Statement SELECT Statement INSERT INTO SELECT Statement Conclusion Before we kick off Before we start we need to make sure […]

August 20, 2020 in MySQL & Snippets

PHP Functions: Remove Last Character From String In PHP

In this tutorial, you’ll learn four methods to remove the last character from a string in PHP. You can use any one of the following methods as per the requirements. I’m assuming that you have basic knowledge of PHP language and have it running on your computer. Contents substr_replace substr rtrim mb_substr Conclusion substr_replace function The […]

August 13, 2020 in Snippets

PHP Add to Array | Push Value to Array PHP – array_push()

In this tutorial we’ll learn how to add one or more elements onto the end of array. Contents Requirements Definition Syntax Description Usage Conclusion Requirements PHP running on your computer Basic knowledge of PHP Text Editor Definition array_push() is a PHP function that is used to add one or more elements onto the end of an […]

August 7, 2020 in Snippets