Skip to content

Instantly share code, notes, and snippets.

View lionrajkumar's full-sized avatar
💭
Must Learn Today

Rajkumar lionrajkumar

💭
Must Learn Today
View GitHub Profile
@lionrajkumar
lionrajkumar / Laravel-Role-Permissions.md
Last active February 21, 2024 11:57
Laravel 8.x User Roles and Permissions Tutorial

User Roles And Permissions Tutorial In Laravel Without Packages

Roles and permissions are an important part of many web applications. In this tutorial we will see how we can implement user roles and permissions system in laravel. We will see it from scratch. We won't use spatie/laravel-permission package for doing it.

It is important to add laravel user roles and permissions mechanism in our large scale application to give the permit to user to specific task. We will see from scratch laravel 8 user roles and permissions tutorial. In this laravel 8 user roles and permissions without package tutorial i don't use any package. We will learn laravel user roles and permissions from scratch with step by step.

If you don't know how to create laravel 8 roles and permissions, then you are a right place. I will teach you from scratch laravel roles and permissions.But in this tutorial we will do user roles and permissions in laravel using our own custom code. So let's start how to implement & setup roles and permi

@lionrajkumar
lionrajkumar / ConvertJsonToPhpClass.md
Created December 21, 2023 17:14
Converting JSON String to PHP class

Converting JSON String to PHP class

class JSONObject {
    public function __construct($json = false) {
        if ($json) $this->set(json_decode($json, true));
    }

    public function set($data) {
 foreach ($data AS $key => $value) {
@lionrajkumar
lionrajkumar / CreateRssFeed.md
Created June 22, 2023 14:08
Creating Valid RSS feed by using PHP and Mysql

Creating Valid RSS feed in PHP

Mysql Table

CREATE TABLE `tbl_post` (
  `id` mediumint(8) UNSIGNED NOT NULL,
  `title` text,
  `description` text,
  `author` varchar(255) DEFAULT NULL,
  `datetime` datetime DEFAULT NULL,
  `image` varchar(150) DEFAULT NULL,
@lionrajkumar
lionrajkumar / MySql-ShutdownUnexpectedly.md
Created January 22, 2021 10:38
XAMMP Control Panel Error when trying start MySql service

XAMMP Control Panel Error when trying start MySql service

7:56:50 AM [mysql] Error: MySQL shutdown unexpectedly.
7:56:50 AM [mysql] This may be due to a blocked port, missing dependencies,
7:56:50 AM [mysql] improper privileges, a crash, or a shutdown by another method.
7:56:50 AM [mysql] Press the Logs button to view error logs and check
7:56:50 AM [mysql] the Windows Event Viewer for more clues
7:56:50 AM [mysql] If you need more help, copy and post this
7:56:50 AM [mysql] entire log window on the forums
@lionrajkumar
lionrajkumar / UpgradeMariaDB.md
Last active May 23, 2023 19:51
Upgrade MariaDB to latest in Xampp

How to upgrade MySQL to MariaDB in XAMPP in 5 minutes on Windows

Here are the steps I used to to upgrad MySQL to MariaDB in XAMPP on Windows in about 5 minutes. After completing this process, MariaDB will look and work just like MySQL. You may even notice a performance increase in your website. No need to panic fellow developer, increased performance is perfectly normal and just one of the great benefits of MariaDB over MySQL.

IMPORTANT: Before you begin, always be sure to make a good backup. Do not do move instead of copy files in the instructions below as the original files may be required in order to back out and restore the original MySQL environment if it doesn't work out for you.

  1. Open a command prompt.
  2. Go to your xampp folder.
  3. Enter the following command: mysql/bin/mysql --version
  4. Take note of the version of MySQL you have installed. This is the version of MariaDB that you will need. You can now exit the command prompt as the rest of the instructions can be done through Windows Explorer

Script Code

<script src="js/checkout.js" STRIPE_PUBLISHABLE_KEY="<?php echo STRIPE_PUBLISHABLE_KEY; ?>" defer></script>

with in the script

// Get API Key
let STRIPE_PUBLISHABLE_KEY = document.currentScript.getAttribute('STRIPE_PUBLISHABLE_KEY');
@lionrajkumar
lionrajkumar / CopyPagesbetweenSitesinMultisiteNetwork.md
Created March 9, 2023 19:28
Copy Pages between Sites in Multisite Network.md

Copy Pages between Sites in Multisite Network

In this tutorial I will show you an easy way to duplicate WordPress pages to any of your sites within a multisite network.

There are different ways to implement that but we going to use WordPress bulk actions.

Copy Pages between Sites within WordPress Multisite network

As an example I decided to use Pages and we do not only copy them, but move between sites. If you need to create duplicates, you will have to change just one line of code.

@lionrajkumar
lionrajkumar / TodoReminder.md
Last active February 21, 2023 12:31
Automate todo list reminder email To specific user on every day with Google Sheets in 5 minutes.

Todo list and Notifications

Automate todo list reminder email To specific user on every day with Google Sheets in 5 minutes.

Google sheets provide a low cost (free), easy to set up, with a low entry barrier for operating staff to update the data, and less error solution in this case as compared to commercial available CRM which have a learning curve and integration requirement.

Step 1: Prepare your Google Sheet

Prepare your google sheet as below, make sure you had formatted the column Due Date to Date format using:

Format → Number → Date

Battery checkup using Javascript

navigator.getBattery().then((battery)=>{
	var btLvl = battery.level*100;
	console.log('battery Level: ' + btLvl );
	
	if(battery.charging){
		console.log('Battery is charging now');
	}else{
@lionrajkumar
lionrajkumar / gitCloneComments.md
Last active December 17, 2022 20:09
git Clone Basic Comments

…or create a new repository on the command line

echo "# sample" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/lionrajkumar/sample.git
git push -u origin main