Skip to content

Instantly share code, notes, and snippets.

View infysumanta's full-sized avatar
🎯
Focusing

Sumanta Kabiraj infysumanta

🎯
Focusing
View GitHub Profile
@infysumanta
infysumanta / URL Subdomain Rewriting Middleware.md
Last active February 14, 2024 06:58
This code snippet is a middleware function that extracts the subdomain from the request's hostname and rewrites the URL if the subdomain is "www" or exists. Otherwise, it allows the request to proceed to the next middleware.

URL Subdomain Rewriting Middleware

Preview:
import { type NextRequest, NextResponse } from "next/server";

export const config = {
  matcher: ["/((?!api/|_next/|_static/|_vercel|[\\w-]+\\.\\w+).*)"],
};

export default function middleware(req: NextRequest) {
@infysumanta
infysumanta / Gitanjali - Rabindranath Tagore.md
Last active February 13, 2024 17:11
The code snippet is a description of the Gitanjali library that translates to "Song Offerings", embodying it essence and humility, his poems resonate with deep longing for union with divine presence innermost sentiments. It also includes information about how

Gitanjali - Rabindranath Tagore

Preview:
"Gitanjali," a masterpiece penned by the celebrated Indian poet Rabindranath Tagore, stands as a testament to the power of spiritual introspection and universal human emotions. Comprising a collection of 103 poems originally written in Bengali, the work was first published in 1910 and later translated into English by Tagore himself. It remains one of his most renowned literary contributions, earning him the Nobel Prize in Literature in 1913, making him the first non-European to receive such an honor.

The title "Gitanjali" translates to "Song Offerings," embodying the essence of devotion and surrender to a higher power. Each poem within the collection serves as a lyrical offering, a heartfelt expression of the poet's profound spiritual journey and his relationship with the divine. Through the verses, Tagore explores themes of love, faith, nature, and the interconnectedness of all existence.

Central to "Gitanjali" is the concept of Bhakti, or devotion,
@infysumanta
infysumanta / Visva-Bharati: India's Cultural Hub of Education and Heritage.md
Last active February 7, 2024 06:56
Visva-Bharati is a prestigious institution of higher learning nestled in the quaint town of Santiniketan, West Bengal, India. Established by legendary Nobel laureate Rabindranath Tagore's educational philosophy for modern education

Visva-Bharati: India's Cultural Hub of Education and Heritage

Visva-Bharati, meaning "The communion of the world with India" in Sanskrit, is a prestigious institution of higher learning nestled in the quaint town of Santiniketan, West Bengal, India. Established by the legendary Nobel laureate Rabindranath Tagore in 1921, Visva-Bharati stands as a symbol of India's rich cultural heritage, blending the essence of Indian traditions with modern education.

At the heart of Visva-Bharati lies its unique educational philosophy, which emphasizes the harmony of the individual with nature and society. Tagore envisioned an educational institution that would break free from the confines of traditional pedagogy, fostering a holistic approach to learning that nurtures creativity, critical thinking, and a deep appreciation for diverse cultures.

One of the distinctive features of Visva-Bharati is its open-air classrooms, where students gather under the shade of trees to engage in discussions, music, dance, and other ar

@infysumanta
infysumanta / Payment with Credit Card using PayPal API.md
Created February 1, 2024 14:47
The code snippet defines two functions. The first function, `getAuthenticationToken`, retrieves an access token for authentication using client credentials. The second function, `paymentWithCard`, handles the payment process using a credit card, including creating an order, capturing

Payment with Credit Card using PayPal API

Preview:
const PAYPAL_CLIENT_ID = process.env.PAYPAL_CLIENT_ID!!;
const PAYPAL_CLIENT_SECRET = process.env.PAYPAL_CLIENT_SECRET!!;
const PAYPAL_MODE = process.env.PAYPAL_MODE;
const SANDBOX_URL = 'https://api-m.sandbox.paypal.com';
const LIVE_URL = 'https://api-m.paypal.com';

const requestUrl = PAYPAL_MODE === 'sandbox' ? SANDBOX_URL : LIVE_URL;
@infysumanta
infysumanta / Dynamic Script Loading for Razorpay Checkout Integration.md
Last active January 30, 2024 20:21
This code snippet loads the Razorpay checkout script dynamically on the client-side. It checks if the script is already loaded and if not, it creates a script tag and appends it to the document body to load the script.

Dynamic Script Loading for Razorpay Checkout Integration

Preview:
const RAZORPAY_SCRIPT = "https://checkout.razorpay.com/v1/checkout.js";

  const isClient = useMemo(() => typeof window !== "undefined", []);

  const [isLoaded, setIsLoaded] = useState(false);

  const checkScriptLoaded: () => boolean = useCallback(() => {
@infysumanta
infysumanta / Encryption Migration.md
Created September 1, 2023 18:13
This code snippet defines a route handler for the root URL ("/") of an app. It retrieves a list of users who do not have a certain field, performs some operations on each user, and then sends a JSON response with a message. This code retrieves a list of users by their ID and updates it with the user's attributes. It then sends an error message t…

Encryption Migration

Preview:
app.get<{}, MessageResponse>('/', async (req, res) => {
  const user = await User.find({ __enc_firstName: { $exists: false } }).select(
    '_id',
  );

  Promise.all(
    user.map(async (u) => {
let flag = true
let timer = setInterval(function () {
document.title = flag ? "<<--- FLAG --->>": "<_*_*_ FLAG _*_*_>";
flag= !flag
}, 1000);
@infysumanta
infysumanta / graphql.js
Last active June 6, 2023 06:43
a graphql query
const express = require("express");
const { graphqlHTTP } = require("express-graphql");
const {
GraphQLSchema,
GraphQLObjectType,
GraphQLString,
GraphQLList,
GraphQLInt,
GraphQLNonNull,
} = require("graphql");
const multer = require("multer");
const uuidv4 = require("uuid/v4");
const storage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, "./public/upload");
},
filename: (req, file, cb) => {
const fileName =
uuidv4() + "-" + file.originalname.toLowerCase().split(" ").join("-");
// SPDX-License-Identifier: GPL-3.0
pragma solidity >= 0.7.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor () ERC20("MyLove Token", "MyLove"){
_mint(msg.sender, 1000000 * 10 ** decimals());
}