Skip to content

Instantly share code, notes, and snippets.

View rajibkuet07's full-sized avatar
🧅
Still Peeling the Onion

Rajib Dey rajibkuet07

🧅
Still Peeling the Onion
View GitHub Profile
@rajibkuet07
rajibkuet07 / terminal-commands.md
Created March 19, 2025 18:15 — forked from bradtraversy/terminal-commands.md
Common Terminal Commands

Common Terminal Commands

Key Commands & Navigation

Before we look at some common commands, I just want to note a few keyboard commands that are very helpful:

  • Up Arrow: Will show your last command
  • Down Arrow: Will show your next command
  • Tab: Will auto-complete your command
  • Ctrl + L: Will clear the screen
@rajibkuet07
rajibkuet07 / ssh.md
Created March 19, 2025 18:14 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets

SSH Cheat Sheet

This sheet goes along with this SSH YouTube tutorial

Login via SSH with password (LOCAL SERVER)

$ ssh [email protected]

Create folder, file, install Apache (Just messing around)

$ mkdir test

$ cd test

@rajibkuet07
rajibkuet07 / nvmCommands.js
Created January 9, 2025 16:13 — forked from chranderson/nvmCommands.js
Useful NVM commands
// check version
node -v || node --version
// list locally installed versions of node
nvm ls
// list remove available versions of node
nvm ls-remote
// install specific version of node
@rajibkuet07
rajibkuet07 / nestjs-prisma-exception.filter.ts
Last active February 22, 2025 10:24
NestJS Prisma Exception Filter
import {
ArgumentsHost,
Catch,
ExceptionFilter,
HttpStatus,
Logger,
} from '@nestjs/common';
import { HttpArgumentsHost } from '@nestjs/common/interfaces';
import { RpcException } from '@nestjs/microservices';
import { status as Status } from '@grpc/grpc-js';
@rajibkuet07
rajibkuet07 / mysql-create-or-update.sql
Last active March 18, 2024 18:07
MySql Create Or Update in Single Query
INSERT INTO `urls`
(`id`,`linkId`,`userId`,`target`,`type`,`order`,`active`,`name`,`createdAt`,`updatedAt`)
VALUES
(2,2,1,'https://example.me',NULL,1,true,'','2024-03-18 15:47:03','2024-03-18 15:47:03'),
(3,2,1,'https://example-1.com',NULL,2,true,'Test note Updated','2024-03-18 15:47:03','2024-03-18 15:47:03'),
(4,2,1,'https://example-2.com',NULL,3,true,'Another Note Updated','2024-03-18 15:47:03','2024-03-18 15:47:03'),
(7,2,1,'https://example-3.com',NULL,4,true,'A New Note','2024-03-18 15:47:03','2024-03-18 15:47:03'),
(NULL,2,1,'https://example-4.com',NULL,5,true,'A New Item Note','2024-03-18 15:47:03','2024-03-18 15:47:03')
ON DUPLICATE KEY UPDATE
`target`=VALUES(`target`),
@rajibkuet07
rajibkuet07 / get-filename-extension.ts
Last active February 29, 2024 14:28
Get Filename and Extension from URL
import axios from 'axios';
import path from 'path';
function extractFilenameAndExtension(url: string): {
fileName: string;
extension: string;
} {
/* Works Only For Absolute URL */
// // get the pathname from the URL
// const pathname = new URL(url).pathname;
@rajibkuet07
rajibkuet07 / check-if-url-is-absolute.ts
Last active February 29, 2024 09:47
Check if URL is absolute
function isAbsoluteUrl(url: string): boolean {
/* Using URL construcor */
try {
new URL(url);
return true;
} catch {
return false;
}
/* Using Regex */
@rajibkuet07
rajibkuet07 / is-valid-image-url.ts
Last active February 29, 2024 14:13
Check If Is Valid Image Url
/* Check if an url is an image url in browser */
async function isImgUrl(url: string) {
const img = new Image();
img.src = url;
return new Promise((resolve) => {
img.onerror = () => resolve(false);
img.onload = () => resolve(true);
});
}
@rajibkuet07
rajibkuet07 / kafka-retry-mechanism.md
Last active April 21, 2024 13:30
Kafka Retry Mechanism

Retry Mechanism in Kafka

  • Create a database table for the retry events - id, topic, partition, message, hash(md5(the unique identifier for the failed message)), offset, counter(count of retry for this message), nextEventTime(DateTime | gradually increase based on the counter), published(false | true whether or not a retry message is published in the topic again), handled(false | true whether the message handled again), status(success | error status of the event when handled again)
  • When an error happens in any consumer emit an event to the retry topic. The retry topic can get a message consisting of hash(md5(the unique identifier for the failed message), topic(topic name of the failed message), partition(partition number of the failed message), message(actual message of the failed message), error(error data or string for which the previous message failed), fallback(optional | {topic: "fallback topic name", value: "fallback message value"} | if max count exceeds then produce this fallback topic with the
@rajibkuet07
rajibkuet07 / md5-hash.js
Created February 21, 2024 14:28
MD5 hash in nodejs
import crypot from crypto;
export const md5 = (value: any): string => {
return crypto.createHash('md5').update(value).digest('hex');
};