Skip to content

Instantly share code, notes, and snippets.

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

Rahul Dutt rahulduttt

🏠
Working from home
View GitHub Profile
@rahulduttt
rahulduttt / app.py
Created August 28, 2025 04:03
Azure OpenAI Multimodal Support
import copy
import json
import os
import logging
import uuid
import httpx
import asyncio
from quart import (
Blueprint,
Quart,
@rahulduttt
rahulduttt / froom-calculator.cpp
Created May 4, 2024 02:59
A simple Froom Calculator
#include <iostream>
double getGroom(double frug) {
const double kon1 = 2.7381;
// frob can also be set as constant but since the question does not explicitly specify it
double frob = 5.4762;
return kon1 * frug / frob;
}
double getDroom(double dros, double dras) {
@rahulduttt
rahulduttt / dynamic-form.html
Created February 9, 2024 12:25
Dynamic Form Vue
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dynamic Form Rendering with Vue.js</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<style>
label {
display: block;
@rahulduttt
rahulduttt / next-auth-middleware.js
Created April 12, 2023 14:00
Working Middleware Sample
import { withAuth } from "next-auth/middleware";
import { NextResponse } from "next/server";
export default withAuth(
// `withAuth` augments your `Request` with the user's token.
function middleware(req) {
console.log(req.nextauth.token);
if (req.nextauth.token.role.name === "admin") {
return NextResponse.redirect(
@rahulduttt
rahulduttt / vscode-settings-23122022.json
Created December 22, 2022 17:20
vscode-settings-23122022
‎‎​
@rahulduttt
rahulduttt / dynamic-fields.js
Created November 27, 2022 21:09
Dynamically Get field And Translation
computed: {
fields: function () {
const temp = [
{
key: 'code',
label: this.labels.code,
data: _.get(this.partner, 'code', 'n/a')
},
{
key: 'name',
@rahulduttt
rahulduttt / handling_multiple_github_accounts.md
Created August 1, 2022 14:19 — forked from Jonalogy/handling_multiple_github_accounts.md
Handling Multiple Github Accounts on MacOS

Handling Multiple Github Accounts on MacOS

The only way I've succeeded so far is to employ SSH.

Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:

Host *
 AddKeysToAgent yes

> UseKeyChain yes

@rahulduttt
rahulduttt / persistStore.js
Created July 25, 2022 11:38
Add Stores to LocalStorage
import { writable } from 'svelte/store';
export const persistStore = (key, initialValue) => {
const persist = localStorage.getItem(key);
const data = persist ? JSON.parse(persist) : initialValue;
const store = writable(data, () => {
const unsubscribe = store.subscribe((value) => {
localStorage.setItem(key, JSON.stringify(value));
});
@rahulduttt
rahulduttt / themeStore.js
Created July 25, 2022 11:18
Persistent Store Svelte
import { browser } from '$app/env';
import { writable } from 'svelte/store';
if (browser) {
const defaultValue = window.matchMedia('(prefers-color-scheme: dark)').matches
? 'dark'
: 'light';
const initialValue = browser
? window.localStorage.getItem('theme') ?? defaultValue
: defaultValue;
@rahulduttt
rahulduttt / EventBus.js
Created June 13, 2022 15:05
EventBus.js
import Vue from '../../build/node_modules/vue';
export const EventBus = new Vue();