Skip to content

Instantly share code, notes, and snippets.

View abhagsain's full-sized avatar
💻
Building

Anurag Bhagsain abhagsain

💻
Building
View GitHub Profile
@abhagsain
abhagsain / .cpp
Created April 30, 2019 02:55
Sorting Algorithms
#include<bits/stdc++.h>
using namespace std;
void show(int arr[], int size){
cout<<"\n";
for(int i = 0; i < size; i++){
cout<<arr[i]<<" ";
}
}
int getMax(int arr[], int size){
int max = arr[0];
@abhagsain
abhagsain / .cpp
Last active April 30, 2019 02:57
Subset Problem
#include<iostream>
using namespace std;
bool isSum(int set[], int size,int sum){
bool subSet[size + 1][sum + 1];
for(int i = 0; i <= size; i++){
subSet[i][0] = true;
}
for(int i = 1; i <= sum; i++){
subSet[0][i] = false;
}
@abhagsain
abhagsain / .cpp
Created April 30, 2019 02:58
BFS & DFS
/*
Write a BFS program using adjacency list and queue
*/
#include<iostream>
#include<list>
#include<queue>
#include<stack>
using namespace std;
class Graph{
private:
@abhagsain
abhagsain / app.js
Created May 27, 2019 22:19 — forked from joshnuss/app.js
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./permission"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@abhagsain
abhagsain / bash.txt
Created September 1, 2019 08:38
Bash commands
BEGINNER'S GUIDE TO THE BASH TERMINAL
NAVIGATION
ls - list directory contents
pwd - print name of current/working directory
cd - change working directory
pushd/popd - put working directory on a stack
file - determine file type
locate - find files by name
@abhagsain
abhagsain / docker-commands.md
Last active September 8, 2019 15:48
I'll be putting docker commands that I'm learning from the course Docker Mastery

Basic docker commands that I'm learning

  • docker container
    • run --publish 80:80 --detch --name {custom_container_name} nginx
    • ls [list all the running containers]
    • ls -a [list all the containers installed]
    • stop {container_id} {give upto 3 characters of the container} [Stops the running container]
    • rm {container_id} [Remove the stoppped container]
    • rm -f [Remove any container; stopped or running] [Not recommended]
    • top (container_name) [displays the running process of the container]
  • inspect (conatiner_name) [details of the container config]
@abhagsain
abhagsain / index.js
Created March 12, 2020 09:06
Protected Route Using React Router Dom
const PrivateRoute = ({ component: Component, ...args }) => {
// user is the authenticated user pulled from the React Context
const { user } = useContext(AuthContext);
return (
<Route
{...args}
render={props => {
return user ? (
<Component {...props} />
@abhagsain
abhagsain / Remove Node Modules Modified > 60 days ago
Created April 11, 2020 06:16
This Linux command removes Node Modules Modified > 60 days ago
find . -maxdepth 2 -name node_modules -type d -mtime +60 -exec rm -rf {} \;
@abhagsain
abhagsain / README.md
Created December 20, 2020 04:08
How to debug Typescript in VSCode

How to Debug TypeScript in VSCode

It was a pain for me to figure out how to debug TS in VSCode. Creating this doc for my reference and it might help you as well.

Have this in your tsconfig.json

 "sourceMap": true,  /* SUPER-DUPER Important Generates corresponding '.map' file. */
 "outFile": "./",    /* Concatenate and emit output to single file. */
@abhagsain
abhagsain / extensions.json
Created December 22, 2020 12:29
Extensions
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"VisualStudioExptTeam.vscodeintellicode",
"johnpapa.vscode-peacock"
]
}