Skip to content

Instantly share code, notes, and snippets.

View Prasundas99's full-sized avatar
🎯
Software Developer

Prasun Das Prasundas99

🎯
Software Developer
View GitHub Profile
@Prasundas99
Prasundas99 / node_nginx_ssl.md
Created April 8, 2023 08:30
Node.js Deployment to Digital Ocean using Ngnix

Node.js Deployment

Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt

1. Sign up for Digital Ocean

If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a

2. Create a droplet and log in via ssh

I will be using the root user, but would suggest creating a new user

using CollegeScoreApp.DTN;
using CollegeScoreApp.Entities;
namespace CollegeScoreApp.Utility.Profile
{
public class ApplicationProfile: AutoMapper.Profile
{
public ApplicationProfile()
{
CreateMap<Colleges, CollegeList>().ReverseMap();
@Prasundas99
Prasundas99 / changeBooleanUsingMongoose.js
Created March 8, 2022 18:27
Mongo query which perform update to Boolean expression in schema
/**
** updating the ticket by using aggregation querry explained
** "$set": replaces the value of a field with the specified value.
** "$eq": Compares two values and returns true or false on weather the values are equivallent or not
** "$status" : performs taks equvalent to n xor 1
** Intution: if false == current value $status change the value otherwise $eq changes
*/
const toggleBoolean = await Model.findByIdAndUpdate(
id,
[{ $set: { status: { $eq: [false, '$status'] } } }],
@Prasundas99
Prasundas99 / schemaValidationForUniqueField.js
Last active March 3, 2022 19:11
mongoose Schema level validation for unique fields
//next referes to middleware
Schema.post('save', function (error, doc, next) {
if (error.code === 11000 && error.keyPattern.item === 1)
next(new Error('This Item already exists, please try again'));
else next(error);
});
import { useEffect } from "react";
import { useLocation } from "react-router-dom";
export default function ScrollToTop() {
const { pathname } = useLocation();
useEffect(() => {
window.scrollTo(0, 0);
}, [pathname]);
@Prasundas99
Prasundas99 / xmlParser.ts
Created September 3, 2021 19:32
Converting JSON toXML& XML to JSON in Node.js using xml2js package in TypeScript
import { parseString, Builder } from "xml2js";
// Convert string/XML to JSON
function toJson(xml: string) {
parseString(xml, { explicitArray: false }, function(error, result) {
console.log(result);
});
}
@Prasundas99
Prasundas99 / SQL_Cheatsheet.md
Last active June 5, 2023 09:15
SQL cheatsheet using xampp

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database using XAMPP

MySQL Locations

  • Xampp /xampp/mysql/bin

Add mysql to your PATH