Skip to content

Instantly share code, notes, and snippets.

View ovarunendra's full-sized avatar
🎯
Focusing

Varunendra Pratap Singh ovarunendra

🎯
Focusing
View GitHub Profile
@ovarunendra
ovarunendra / App.jsx
Created April 24, 2023 01:31
PKCE flow with a ReactJS
import React, { useEffect } from 'react';
import { login, logout, handleRedirectCallback, getToken } from './auth';
const App = () => {
useEffect(() => {
handleRedirectCallback();
}, []);
const handleLogin = async () => {
await login();
@ovarunendra
ovarunendra / keyify-byString.js
Created September 4, 2021 03:46
Object to Nested Keys (VV)
var jsData = {
tabs: {
home: 'HOME',
explore: 'EXPLORE',
sell: 'SELL',
blogs: 'BLOGS',
profile: 'PROFILE',
},
homeScreen: {
title: 'Pashushala',
@ovarunendra
ovarunendra / eslint_prettier_airbnb.md
Created August 17, 2019 02:53 — forked from bradtraversy/eslint_prettier_airbnb.md
ESLint, Prettier & Airbnb Setup

VSCode - ESLint, Prettier & Airbnb Setup

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-node
@ovarunendra
ovarunendra / regex.js
Created January 25, 2019 15:24
MAC-IP-PORT JS Regex
const MAC_REGEX = '^[a-zA-Z0-9]{12}$';
const IP_REGEX = '(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}';
const PORT_REGEX = '(?::+(\\d{2,4}))?';
const IP_PORT_REGEX = `(${IP_REGEX})${PORT_REGEX}`;
const MAC_IP_PORT_REGEX = `(^${MAC_REGEX}$)|(^${IP_PORT_REGEX}$)`;
@ovarunendra
ovarunendra / index.html
Created August 5, 2018 12:10
JS Bin findLongestConseqSubseq // source https://jsbin.com/facezoq
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="findLongestConseqSubseq">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
@ovarunendra
ovarunendra / ReadMe.md
Created August 24, 2017 09:37
awesome-graphql
@ovarunendra
ovarunendra / info.txt
Created April 28, 2017 11:28
Generate your React Native app icons in a single command line
ref: https://medium.com/bam-tech/generate-your-react-native-app-icons-in-a-single-command-line-145af2e329b2
remove alpha:
convert image.png -background white -alpha remove white.png
@ovarunendra
ovarunendra / dedup.js
Last active February 17, 2017 08:47
Deduplicate an Array
function dedup(arr) {
var hashTable = {};
return arr.filter(function (el) {
var key;
if (Object.prototype.toString.call(el) === "[object Object]") {
key = JSON.stringify(Object.keys(el).sort());
Object.keys(el).forEach(function(i){
key += JSON.stringify(el[i]);
});
} else {
@ovarunendra
ovarunendra / resize.js
Created October 28, 2016 21:08
Javascript Image Resize
$(document).ready(function() {
$('.small-img img').each(function() {
var maxWidth = 100; // Max width for the image
var maxHeight = 100; // Max height for the image
var ratio = 0; // Used for aspect ratio
var width = $(this).width(); // Current image width
var height = $(this).height(); // Current image height
// Check if the current width is larger than the max
if(width > maxWidth){
@ovarunendra
ovarunendra / self-signed certificate
Last active October 27, 2016 09:34
How to create an https server?
$openssl genrsa -out client-key.pem 2048
$openssl req -new -key client-key.pem -out client.csr
$openssl x509 -req -in client.csr -signkey client-key.pem -out client-cert.pem