Skip to content

Instantly share code, notes, and snippets.

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

Vignesh Ramesh VRamazing

🏠
Working from home
View GitHub Profile
@VRamazing
VRamazing / mongoose.js
Created March 13, 2025 11:40
Mongoose Schema and queries
const mongoose = require('mongoose');
const express = require('express');
const app = express();
const PORT = 3000;
app.use(express.json());
// Set mongoose strictQuery
mongoose.set('strictQuery', true);
@VRamazing
VRamazing / appmodel.js
Created February 20, 2025 15:29
Mongoose model
require('dotenv').config();
// TODO move to singleton pattern
const mongoose = require("mongoose")
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true }, (err)=> {
console.log("DB Error", err)
});
@VRamazing
VRamazing / ShortestPath.py
Created February 15, 2025 16:44
Shortest Path
my_graph = {
'A': [('B', 5), ('C', 3), ('E', 11)],
'B': [('A', 5), ('C', 1), ('F', 2)],
'C': [('A', 3), ('B', 1), ('D', 1), ('E', 5)],
'D': [('C',1 ), ('E', 9), ('F', 3)],
'E': [('A', 11), ('C', 5), ('D', 9)],
'F': [('B', 2), ('D', 3)]
}
def shortest_path(graph, start, target = ''):
@VRamazing
VRamazing / arithmeticArranger.py
Created February 9, 2025 12:56
Arithmetic Arranger
def arithmetic_arranger(problems, show_answers=False):
n = len(problems)
ans_objects = []
if n > 5:
return "Error: Too many problems."
for i, problem in enumerate(problems):
first, oper, second = problem.split(" ")
l1, l2 = len(first), len(second)
@VRamazing
VRamazing / passwordgenerate.py
Created February 9, 2025 12:54
Password generator
import re
import secrets
import string
def generate_password(length=16, nums=1, special_chars=1, uppercase=1, lowercase=1):
# Define the possible characters for the password
letters = string.ascii_letters
digits = string.digits
@VRamazing
VRamazing / BinarySearchSqRoot.py
Last active February 9, 2025 12:57
BinarySearchToFindSquareRoot
def square_root_bisection(square_target, tolerance=1e-7, max_iterations=100):
if square_target < 0:
raise ValueError('Square root of negative number is not defined in real numbers')
if square_target == 1:
root = 1
print(f'The square root of {square_target} is 1')
elif square_target == 0:
root = 0
print(f'The square root of {square_target} is 0')
else:
@VRamazing
VRamazing / Expense_tracker.py
Last active February 9, 2025 12:58
Expense_tracker.py
def add_expense(expenses, amount, category):
expenses.append({'amount': amount, 'category': category})
def print_expenses(expenses):
for expense in expenses:
print(f'Amount: {expense["amount"]}, Category: {expense["category"]}')
def total_expenses(expenses):
return sum(map(lambda expense: expense['amount'], expenses))
@VRamazing
VRamazing / index.html
Created October 13, 2021 13:11
ReactJS Stopwatch
<div id="container"></div>
@VRamazing
VRamazing / index.html
Created October 13, 2021 13:04
ReactJS Stopwatch
<div id="container"></div>
@VRamazing
VRamazing / graphs.js
Created September 23, 2019 13:45
DFS, BFS algorithm
function Graph(v){
this.vertices = v;
this.edges = 0;
this.adj = []
for(var i=0; i<this.vertices; ++i){
this.adj[i]=[];
// this.adj[i].push("");
}
this.addEdge = addEdge;
this.showGraph = showGraph;