Skip to content

Instantly share code, notes, and snippets.

View kavitshah8's full-sized avatar

Kavit Shah kavitshah8

  • Adobe
  • Bay Area, CA
View GitHub Profile
@kavitshah8
kavitshah8 / ticTacToe.cpp
Created March 22, 2021 16:35
Code Sample For Aarjav
#include <stdio.h>
main()
{
int a[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int turn = 1;
int pos;
char pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8, pos9;
char name1[100], name2[100];

To setup your Visual Studio Code to run prettier to reprint the code on File Save follow these steps.

Now when you will save your file it will use ESLint --fix option which will run prettier to reprint entire code. Then it will run ESLint rules to catch the actual bugs in your code. This will also show red squiggly lines with errors.

  • Prettier Error Example: Delete ,eslint(prettier/prettier)
  • ESLint Error Example: Parsing error: Unexpected token {eslint
@kavitshah8
kavitshah8 / reversePolishNotation.js
Last active October 9, 2020 06:49
Stack Based Interview Questions
function RPN (seq) {
if (seq.length <= 2) {
console.log('Please enter valid RPN');
return;
}
let operands = ['+', '-', '*', '/' ],
stack = [],
i = 0;
const nodeInfoMap = require.native("torq-native/dom").nodeInfoMap;
export default class ComponentSelector extends React.Component {
constructor(props) {
super(props);
this.updateComponent = this.updateComponent.bind(this);
this.state = {
component: null
};
@kavitshah8
kavitshah8 / bind.js
Last active July 9, 2019 04:35
Frequently Asked Javascript Interview Questions
Function.prototype.bind1 = function (scope) {
let fn = this
let prefixArgs = Array.prototype.slice.call(arguments, 1)
return function() {
let suffixArgs = Array.prototype.slice.call(arguments)
let args = prefixArgs.concat(suffixArgs)
return fn.apply(scope, args)
}
}
@kavitshah8
kavitshah8 / formatNumber.js
Last active October 8, 2020 05:40
Numbers / Math / Puzzles
function formatNumber (num) {
if (typeof num !== 'number') {
console.error('Incorrect value was passed. Please enter a valid number')
return
}
let isNegativeNum
let isFloatingNum
function isZeroArr(arr) {
if (!arr.length) return false
for (let i = 0; i < arr.length - 1; i++) {
if (arr[i] != 0) return false;
}
return true;
}
function isPossible(row, folks) {
var rowLen = row.length
@kavitshah8
kavitshah8 / mutiple-entry-points.js
Last active October 28, 2018 17:02
Webpack Configs
var config = {
entry: {
app: addEntryPoint('./src/Router.jsx'),
vendor: ['lodash', 'react', 'react-router', 'react-dom', 'rc-slider']
},
output: {
path: options.devServer ? path.join( __dirname, 'public', 'js') : 'public',
filename: '[name]-[chunkhash].js',
publicPath: '',
@kavitshah8
kavitshah8 / timeConvertor.js
Last active October 26, 2016 04:18
Hacker
function timeConvertor(time) {
var PM = time.match('PM') ? true : false
time = time.split(':')
var min = time[1]
if (PM) {
var hour = 12 + parseInt(time[0],10)
var sec = time[2].replace('PM', '')
@kavitshah8
kavitshah8 / curry-3.js
Last active July 20, 2016 15:10
Currying
function realSum(a, b) {
return a + b;
};
console.log(realSum(5, 3)); // 8
var sum5 = curryIt(realSum, 5);
console.log(sum5(4)); // 9