Skip to content

Instantly share code, notes, and snippets.

@Prottoy2938
Prottoy2938 / ch-key-generation.js
Created November 2, 2020 13:17
Cipher Delta key generation code
function makeId(length) {
let result = "";
const characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
const charactersLength = characters.length;
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
@Prottoy2938
Prottoy2938 / Dijkstra's-algorithm.js
Created March 18, 2020 10:02
Dijkstra's algorithm implementation in JavaScript
//Dijkstra algorithm is used to find the shortest distance between two nodes inside a valid weighted graph. Often used in Google Maps, Network Router etc.
//helper class for PriorityQueue
class Node {
constructor(val, priority) {
this.val = val;
this.priority = priority;
}
}
@Prottoy2938
Prottoy2938 / rgba-to-css-filter.js
Last active July 28, 2025 05:32
RGBA To CSS Filter Converter. This code is a slightly modified version of this stackoverflow answer: https://stackoverflow.com/a/43960991/604861
"use strict";
class Color {
constructor(r, g, b) {
this.set(r, g, b);
}
toString() {
return `rgb(${Math.round(this.r)}, ${Math.round(this.g)}, ${Math.round(
this.b
)})`;
@Prottoy2938
Prottoy2938 / asdfadf.js
Last active September 5, 2024 01:34
asdfadf
//get the nth number in fibonacci sequence, base case is 0 and 1.
//solution 1, easier to understand but it's not good. It has a time complexity of O(2^n).
function fib(num) {
if (num === 2) return 1;
if (num === 1) return 0;
return fib(num - 1) + fib(num - 2);
}
fib(6) //returns 5
@Prottoy2938
Prottoy2938 / binarySearchTree.js
Last active September 3, 2024 10:02
Binary Search Tree implementation in JavaScript
// A binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child.
// Left child is always less than it's parent and the right child is always bigger than it's parent.
class Node {
constructor(value) {
this.value = value;
this.right = null;
this.left = null;
}
}
@Prottoy2938
Prottoy2938 / history.jsx
Created May 10, 2024 11:25
History Section
import React, { useRef, useEffect, useState } from "react";
import { RxCross2 } from "react-icons/rx";
import { motion } from "framer-motion";
import { BiDotsHorizontalRounded } from "react-icons/bi";
import { useLocation } from "react-router-dom";
import { Rings } from "react-loader-spinner";
function checkIfArraysEmpty(obj) {
for (let key in obj) {
if (Array.isArray(obj[key]) && obj[key].length > 0) {
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const privateKey = "";
const clientEmail = "";
const projectId = "";
if (!admin.apps.length) {
admin.initializeApp({
credential: admin.credential.cert({
@Prottoy2938
Prottoy2938 / test.json
Created December 21, 2023 10:59
Postmaptest.json
{"UserId":"12xxxx",
"PlatformID": ["twitter"],
"Description": "Hello World",
"Hashtags": ["#watch", "#cartier"],
"Mentions": ["@someone", "@else", "@here"],
"Image": ["data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAeAB4AAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCAHgAnEDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEA
@Prottoy2938
Prottoy2938 / bluedeli-product-page.liquid
Created November 21, 2023 22:21
bluedeli-product-page upwork
{% comment %}
@param class_root {String}
Base class root
@param show_range {Bool}
Show price range
@param price_range_format {String}
'range' or 'from', defaults to 'range'
@Prottoy2938
Prottoy2938 / delete.json
Created June 20, 2023 09:28
Chaptgpt prompt
[
{
"role": "system",
"content": "Imagine you're an expert product reviewers that tries to give insight on specific and important details based on reviews"
},
{
"role": "user",
"content": "This is the first product: Budge Lite Car Cover Dirtproof, Scratch Resistant, Breathable, Dustproof, Car Cover Fits Sedans up to 264\", Gray and here are its reviews from other people, I'll send more reviews in a bit: [{\"rating\":\"5.0 out of 5 stars\",\"title\":\"5.0 out of 5 stars\\n\\n\\n\\n\\n\\n\\n\\n \\n \\n Not suitable for 98+ Lincoln hood ornament modifications\",\"text\":\"I ordered this cover for a 1998 Lincoln Town Car. Its the right size, it wards off dust just like it says. I ordered just the dust cover and surprisingly its a tad “water resistant”. By that i mean any part of the cover that isn’t directly laying flat on your car will “roll” water off the side. Pretty cool! I ordered and used Amazon’s size confirming feature to make sure it would fit the 1998 lincoln town car i meant