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 / demo.js
Last active January 15, 2021 17:40
Rapid Poll
import React from "react";
import cx from "classnames";
const Label = ({ children }) => {
return (
<label className="mb-3 w-full font-semibold text-gray-600">
{children || "Label"}
</label>
);
};
const ErrorLabel = ({ children }) => {
@abhagsain
abhagsain / file.md
Last active February 5, 2021 14:19
Extensions that I use
  • alefragnani.Bookmarks
  • bradlc.vscode-tailwindcss
  • ChakrounAnas.turbo-console-log
  • CoenraadS.bracket-pair-colorizer
  • dbaeumer.vscode-eslint
  • donjayamanne.githistory
  • dsznajder.es7-react-js-snippets
  • eamodio.gitlens
  • Equinusocio.vsc-community-material-theme
  • Equinusocio.vsc-material-theme
@abhagsain
abhagsain / getFuzzyTime.js
Created February 20, 2021 13:15
Get fuzzy time from JS Date.
// 1hr ago, 2 days ago etc
const getFuzzyTime = (millisec) => {
let res = "";
const t_second = 1000;
const t_minute = t_second * 60;
const t_hour = t_minute * 60;
const t_day = t_hour * 24;
const t_week = t_day * 7;
const t_month = Math.floor(t_day * 30.4);
@abhagsain
abhagsain / currencies.js
Created March 23, 2021 19:51
List of World Currencies with Code, Symbol and Name
const currencies = {
ADP: {
code: 'ADP',
name: 'Andorran peseta',
currencySymbol: 'ADP',
symbol: 'ADP',
},
AED: {
code: 'AED',
name: 'UAE dirham',
@abhagsain
abhagsain / deleteProcessWindows.sh
Last active August 16, 2023 05:14
How to kill process on port in Windows
```
# Run this in CMD only and not in bash
netstat -ano | findstr :3001
# This will give
TCP 0.0.0.0:3001 0.0.0.0:0 LISTENING 24928 👈
TCP [::]:3001 [::]:0 LISTENING 24928
@abhagsain
abhagsain / getStringDotRefFromObject.js
Created October 12, 2021 15:19
Convert Object Reference to String dot Notation JavaScript
function getStringDotRefFromObject(obj, arr = [], objPath = '') {
const isObject = typeof obj === 'object' && !Array.isArray(obj) && obj !== null;
if (!isObject) return objPath;
return Object.keys(obj).reduce((acc, curr) => {
const path = obj[curr];
return acc.concat(
// eslint-disable-next-line prefer-template
getStringDotRefFromObject(path, arr, `${objPath ? objPath + '.' : ''}${curr}`)
);
}, []);
@abhagsain
abhagsain / install-docker.sh
Last active January 13, 2022 02:02
Install Docker On Ubuntu
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt install docker.io -y
systemctl start docker
systemctl enable docker
docker --version
@abhagsain
abhagsain / serverless.yml
Created May 22, 2022 06:19
How to use Lambda Layer With Serverless Framework
org: abhagsain
app: abhagsain-app
service: abhagsain-app
frameworkVersion: "3"
provider:
name: aws
runtime: python3.8
httpApi:
cors: true
@abhagsain
abhagsain / .vimrc
Last active April 21, 2024 16:19
Install OhMySh, PowerLeve10K, Autosuggestion and Syntax highlighting On Ubuntu
# set relative line number in vim
set number
set rnu
@abhagsain
abhagsain / getGoogleAuthToken.js
Created January 17, 2023 13:10 — forked from markelliot/getGoogleAuthToken.js
Converts Google service user OAuth2 credentials into an access token in Cloudflare-compatible JS
/**
* Get a Google auth token given service user credentials. This function
* is a very slightly modified version of the one found at
* https://community.cloudflare.com/t/example-google-oauth-2-0-for-service-accounts-using-cf-worker/258220
*
* @param {string} user the service user identity, typically of the
* form [user]@[project].iam.gserviceaccount.com
* @param {string} key the private key corresponding to user
* @param {string} scope the scopes to request for this token, a
* listing of available scopes is provided at