Skip to content

Instantly share code, notes, and snippets.

View souravrane's full-sized avatar
🥷
Learning code breathing

Sourav Rane souravrane

🥷
Learning code breathing
  • India
View GitHub Profile
@souravrane
souravrane / ScrollManager.jsx
Created June 4, 2020 10:39 — forked from jeffijoe/ScrollManager.jsx
Save and restore scroll position in React
/*
The MIT License
Copyright (c) Jeff Hansen 2018 to present.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION W
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char ip_sym[15],stack[15];
int ip_ptr=0,st_ptr=0,len,i;
char temp[2];
char act[15];
void check();
void main()
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char prod [3][10]={"A->aBa","B->bB","B->@"};
char first[3][10]={"a","b","@"};
char follow[3][10]={"$","a","a"};
char table[3][4][10];
char input[10];
int top=-1;
char stack[25];
@souravrane
souravrane / CubeRotate.c
Last active April 6, 2018 19:30
OpenGL - Cube rotation along different axes
#include<stdio.h>
#include<GL/glut.h>
#include<math.h>
float v[][3] = { {-1,-1,-1} ,{ -1,1,-1 } ,{ 1,1,-1 } ,{ 1,-1,-1 } ,{ -1,-1,1 } ,{ -1,1,1 } ,{ 1,1,1 } ,{ 1,-1,1 } }; // 8 vertices of the cube with origin as its centroid
int t[] = { 0,0,0 }; // degree of rotation along {x,y,z}
int ax = 2; // axis of rotation
@souravrane
souravrane / Lineclip.cpp
Created April 5, 2018 17:15
OpenGL - Line clipping algorithm ( c++ program )
#include<stdio.h>
#include<GL/glut.h>
int xmax = 100, ymax = 100, xmin = 50, ymin = 50, x1 = 80, y1 = 120, x0 = 60, y0 = 20, left = 8, right = 2, bottom = 1, top = 4, x, y;
float m = (y1 - y0) / (x1 - x0);
void Init()
{
gluOrtho2D(0, 400, 0, 400);
@souravrane
souravrane / Scanline.c
Last active January 12, 2024 00:53
OpenGL - Scanline filling algorithm
#include<stdio.h>
#include<GL/glut.h>
#include<math.h>
int le[500], re[500], flag=0 ,m;
void init()
{
@souravrane
souravrane / TriangleRotate.c
Created April 5, 2018 14:57
OpenGL - Triangle rotation about any given point
/* LAB 2: ROTATION OF TRIANGLE ABOUT A GIVEN POINT*/
#include<stdio.h>
#include<GL/glut.h>
#include<math.h>
#define pi 3.1415
float tri[4][4] = { { 150.0,250.0,350.0 } ,{ 250.0,350.0,250.0 },{ 1.0,1.0,1.0 },{ 1.0,1.0,1.0 } };
float rotate[4][4], result[4][4], angle=90, h=150,k=250;
float theta = pi / 180.0;
@souravrane
souravrane / BresenLine.c
Last active December 16, 2023 05:50
OpenGL - Bresenham's Line drawing algorithm
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<GL/glut.h>
int xstart, ystart, xend, yend;
void init()
{