Skip to content

Instantly share code, notes, and snippets.

View susanta96's full-sized avatar
🌴
On vacation

Susanta Chakraborty susanta96

🌴
On vacation
View GitHub Profile
@susanta96
susanta96 / LazyLoad.js
Created April 14, 2020 15:46
Lazy Load using Intersection Observer
LazyLoadImages = () => {
const images = document.querySelectorAll("[data-src]");
const options = {
rootMargin: "0px 0px 200px 0px"
};
const imgObserver = new IntersectionObserver((entries, imgObserver) => {
entries.forEach(entry => {
if(!entry.isIntersecting){
return;
@susanta96
susanta96 / NavBarHightlight.js
Created April 14, 2020 15:26
Navbar Style Changes using Intersection Observer API without scroll
const NavHighlight = (navbar, mobileNav, section, options) => {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if(!entry.isIntersecting){
console.log('not');
mobileNav.classList.add('box-shadow');
navbar.classList.add('box-shadow');
}else {
console.log('yes');
mobileNav.classList.remove('box-shadow');
toHHMM = (secs) => {
var hours = Math.floor(secs / 3600) < 10 ? ("00" + Math.floor(secs / 3600)).slice(-2) : Math.floor(secs / 3600);
var minutes = ("00" + Math.floor((secs % 3600) / 60)).slice(-2);
return hours + ":" + minutes;
}
set @r1=0, @r2=0, @r3=0, @r4=0;
select min(Doctor), min(Professor), min(Singer), min(Actor)
from(
select case when Occupation='Doctor' then (@r1:=@r1+1)
when Occupation='Professor' then (@r2:=@r2+1)
when Occupation='Singer' then (@r3:=@r3+1)
when Occupation='Actor' then (@r4:=@r4+1) end as RowNumber,
case when Occupation='Doctor' then Name end as Doctor,
case when Occupation='Professor' then Name end as Professor,
case when Occupation='Singer' then Name end as Singer,
SELECT concat(NAME,concat("(",concat(substr(OCCUPATION,1,1),")"))) FROM OCCUPATIONS ORDER BY NAME ASC;
SELECT "There are a total of ", count(OCCUPATION), concat(lower(occupation),"s.") FROM OCCUPATIONS GROUP BY OCCUPATION ORDER BY count(OCCUPATION), OCCUPATION ASC
###Hackerranks solve SQL ###
select H.hacker_id, H.name from Hackers As H, Submissions AS S, Challenges AS C, Difficulty AS D where S.challenge_id = C.challenge_id AND C.difficulty_level = D.difficulty_level AND S.hacker_id = H.hacker_id AND S.score = D.score group by H.hacker_id, H.name having count(S.hacker_id) > 1 order by count(S.hacker_id) desc, S.hacker_id asc;
@susanta96
susanta96 / VectorAddMultSub.cpp
Created February 8, 2018 20:19
Simple example of vector addition , subtraction and multiplication
#include<iostream>
#include<stdlib.h>
using namespace std;
class Vector
{
int a,b,c;
public:
Vector(int x,int y,int z)
{
a=x;
@susanta96
susanta96 / STUDENT_INFO_SYS.cpp
Created February 8, 2018 20:16
Student Management System in C++ with CRUD operations
#include<iostream>
#include<stdlib.h>
using namespace std;
class STUDENT
{
int STU_ROLL;
char STU_NAME[20];
char STU_SEC[20];
char STU_DEPT[20];
public:
@susanta96
susanta96 / Prim'sAlgo.c
Created February 8, 2018 20:11
Prim's Algorithm in C program Working code
#include<stdio.h>
#include<conio.h>
int visited[10]={0}, cost[10][10], min, mincost=0;
int input(int);
int display(int);
int prims(int);
int input(int num)
{
int i, j;
@susanta96
susanta96 / mcm.c
Created February 8, 2018 20:05
Matrix Chain Multiplecation program with M table and S table in C
#include<stdio.h>
int main()
{
int i,j,k,pass,n;
int m[20][20],s[10][10],p[10],result;
printf("Enter the elements:");
scanf("%d",&n);
printf("Enter the value of P:");
for(i=0;i<=n;i++)