Skip to content

Instantly share code, notes, and snippets.

View cptiwari20's full-sized avatar
🏠
Working from home

Chandra Prakash Tiwari cptiwari20

🏠
Working from home
View GitHub Profile
@cptiwari20
cptiwari20 / Example.txt
Created July 11, 2022 05:35
Idea to structure your React Application for better code management.
src
screens - all the main screens
Home
index.js
style.scss/css
@cptiwari20
cptiwari20 / fontawesomeController.php
Created November 13, 2021 16:13
Fetch and Search the fontawesome pro icons using graphql api in Laravel application.
<?php
namespace App\Http\Controllers\Tenant\Integrations;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use function GuzzleHttp\json_decode;
@cptiwari20
cptiwari20 / iconsList.js
Created October 25, 2021 15:43
FontAwesome 5 Pro icon name list including Solid, light, regular and brands.
const iconsString = `
fas fa-abacus,
fas fa-acorn,
fas fa-ad,
fas fa-address-book,
fas fa-address-card,
fas fa-adjust,
fas fa-air-conditioner,
fas fa-air-freshener,
fas fa-alarm-clock,
@cptiwari20
cptiwari20 / Create Pabbly Subscriptions for your node.js app
Created September 14, 2020 16:56
Mange Pabbly payment in nodejs using pabbly Checkout Page
const url = "https://payments.pabbly.com/api/v1";
const auth = {
auth: {
username: process.env.PABBLY_API_KEY,
password: process.env.PABBLY_API_SECRET
}
}
// VerifyToken and create subscription
// Pabbly returns a hostedpage token after successful redirection, we can fetch that and use it for subscribing users.
@cptiwari20
cptiwari20 / Pabbly Webhook Handler
Created September 14, 2020 16:51
Handle Pabbly webhook events for your nodejs application
const pabblyWebhook = async (req, res, next) => {
if(req.body.event_name === 'test_webhook_url') return res.status(200).json({status: true, message: 'Tested data found'})
if(!req.body.data) return res.status(422).json({status: false, message: 'No data found'})
if(!req.body.event_type) return res.status(422).json({status: false, message: 'No event_type found'})
if(!req.body.data.id) return res.status(422).json({status: false, message: 'No id found'})
const subscription_id = req.body.data.id
try {
@cptiwari20
cptiwari20 / ThriveCart Webhook Handler
Created September 14, 2020 16:35
Handle Thrivecart events in Node.js Expressjs API
const Subscriptions = require("../models/subscriptions"); //Any Subscription Model
const Users = require("../models/users"); // User Model
const Plans = require("../models/plans"); // Plans Model
const Payments = require('../models/payments')
const { send: sendMail } = require('../services/smtp');
const { generatePassword, getExpiryDate } = require('../utils/helpers');
let thrivecart_secret = process.env.THRIVECART_SECRET; //Add your API Secret in .env file
@cptiwari20
cptiwari20 / videoLink_helper.php
Last active April 26, 2022 11:45
A laravel helper that will convert any video link from youtube and Vimeo into the embed iframe link. You can use it in HTML or anywhere.
@cptiwari20
cptiwari20 / main.dart
Created November 20, 2019 16:18
Deck Game
void main() {
var deck = new Deck();
// deck.shuffle(); //shuffle the list of cards inside deck
print(deck.cardsWithSuit('Hearts'));
deck.removeCard('Diamonds', 'Ace');
// print(deck);
print(deck.deal(10));
print(deck);
}
@cptiwari20
cptiwari20 / adultBw3040.js
Created May 12, 2019 12:28
a JavaScript method receiving an array of objects containing name+age+gender, returning everyone between 30 and 40 years old grouped by gender.
//people array will be needed
function adultBw3040(peopleArray){
return peopleArray.filter(person => (person.age >= 30 ) && (person.age <= 40 ))
}
const express = require('express');
const app = express();
var port = 3000 || process.env.PORT;
app.listen(port, ()=>{
console.log('Server has been started! Live Port:', port);
}