Skip to content

Instantly share code, notes, and snippets.

View sujaykundu777's full-sized avatar
🚀
focusing

Sujay Kundu sujaykundu777

🚀
focusing
View GitHub Profile
@sujaykundu777
sujaykundu777 / flask_postgres.py
Last active December 4, 2023 08:30
Flask SQLAlchemy Connection with Postgres
from flask import Flask, render_template
from flask_sqlalchemy import SQLAlchemy
POSTGRES_URL= '127.0.0.1:5432'
POSTGRES_USER= 'postgres'
POSTGRES_PW = 'dbpw'
POSTGRES_DB = 'test'
SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://{user}:{pw}@{url}/{db}'.format(user=POSTGRES_USER,pw=POSTGRES_PW,url=POSTGRES_URL,db=POSTGRES_DB)
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_ECHO = True
@sujaykundu777
sujaykundu777 / kadane.c
Created July 25, 2017 18:41
Kadane's Algorithm Implementation in C
#include<stdio.h>
//Function to calculate the maximum sum of a sub-array of a given array
int maxSumarray(int a[], int size){
int i;
int max_sum_so_far=0;
int max_ending_here = 0;
for(i=0;i<size;i++){
max_ending_here = max_ending_here + a[i];
@sujaykundu777
sujaykundu777 / rle.cs
Created July 13, 2017 16:05
Run Length Encoding in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Write a C# program to implement the below compress the given string using Run Length Algorithm
namespace RunLengthEncoder
{
class Program
@sujaykundu777
sujaykundu777 / Dockerfile
Created February 6, 2020 07:05
docker config to deploy jekyll blog using github actions
# Our Docker image will be based on ruby:2-slim
# it is a very light docker image.
FROM ruby:2-slim
LABEL author="Sujay Kundu"
LABEL version="1.0.0"
# Lets install all dependencies
# including git and Bundler 2.1.4
ENV BUNDLER_VERSION 2.1.4
RUN apt-get update && \
#!/bin/python3
import math
import os
import random
import re
import sys
def cycleStr(s):
@sujaykundu777
sujaykundu777 / test1.js
Created October 10, 2020 04:40
test1 sol
'use strict';
const fs = require('fs');
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
let res = '';
@sujaykundu777
sujaykundu777 / file_upload.js
Created August 28, 2020 08:05
File Upload Multer Node API
import express from 'express';
import multer from 'multer';
import Image from './../models/upload.model';
const router = express.Router();
// multer local storage
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './uploads');
@sujaykundu777
sujaykundu777 / dark_mode.js
Last active August 1, 2020 07:26
customizing devlopr-jekyll
/* Switch to Dark Mode Only */
function modeSwitcher() {
sessionStorage.setItem('theme', 'dark');
let theme = sessionStorage.getItem('theme');
document.documentElement.setAttribute('data-theme', 'dark');
}
$(document).ready(function () {
modeSwitcher();
});
@sujaykundu777
sujaykundu777 / cy_sample.spec.js
Last active May 17, 2020 15:39
cypress sample test cases
// example test case
describe("Test Case Name", () => {
// Test case goes here
it("test case name", () => {
// cypress commands goes here
cy.visit("/");
@sujaykundu777
sujaykundu777 / blog_post_breadcrumb.html
Created May 17, 2020 08:26
Blog post Breadcrumb (inside _includes)
<div class="col-lg-11 offset-md-1">
<nav aria-label="breadcrumb" role="navigation">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{{site.url}}{{site.baseurl}}/blog"><i class="fa fa-home" aria-hidden="true"></i></a>
</li>
<li class="breadcrumb-item active" aria-current="page"><a href="{{page.url}}">{{ page.title }}</a></li>
</ol>
</nav>
</div>