Skip to content

Instantly share code, notes, and snippets.

View pratikdevdas's full-sized avatar
🏠
Working from home

Pratik Dev Das pratikdevdas

🏠
Working from home
View GitHub Profile
@pratikdevdas
pratikdevdas / average.js
Last active June 12, 2021 13:31
Small snippets used in web dev testing
//ex.1: simple array
const average = (array) => {
const reducer = (sum, item) => {
return sum + item
}
return array.reduce(reducer, 0) / array.length
}
console.log(average([6,3,5,6]))
//output : 5
@pratikdevdas
pratikdevdas / reducer.js
Last active December 17, 2021 11:08
Using Redux Increment/Decrement with switch case
import React from 'react';
import ReactDOM from 'react-dom';
// import App from './App';
import { createStore } from 'redux';
const counterReducer = (state = 0,action) => {
switch(action.type){
case 'INCREMENT':
return state + 1
@pratikdevdas
pratikdevdas / reduxcounter.js
Created December 9, 2021 08:46
Simple counter app with redux
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore } from 'redux';
const counterReducer = (state = 0,action) => {
switch(action.type){
case 'INCREMENT':
return state + 1
case 'DECREMENT':
return state - 1
@pratikdevdas
pratikdevdas / bookmarks.html
Created December 20, 2021 02:51
Brave Bookmarks
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1639744473" LAST_MODIFIED="1639967469" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks</H3>
<DL><p>
@pratikdevdas
pratikdevdas / conditionalRendering.js
Created December 26, 2021 13:00
conditional rendering must remember
const addBlog = () => {
const newBlog = {
title: newTitle,
author: newAuthor,
url: newUrl,
}
if(newBlog.title.length<4)
{
return console.log('give longer value')
@pratikdevdas
pratikdevdas / settings.json
Last active April 2, 2022 23:44
Vscode settings
//global settings of my vs code
{
"workbench.activityBar.visible": true,
"explorer.confirmDelete": false,
"liveServer.settings.donotShowInfoMsg": true,
"liveServer.settings.donotVerifyTags": true,
"files.associations": {
"*.js": "javascript"
},
@pratikdevdas
pratikdevdas / .eslintignore
Last active December 18, 2023 23:28
eslint & Prettier 05/04/2022 for React
node_modules
build
.eslintrc.js
.prettierrc.js
.eslintcache
@pratikdevdas
pratikdevdas / reactlocal.json
Last active June 27, 2022 18:29
Onsave formatting for react which uses prettier and es-lint both
{
"emmet.includeLanguages": {
"javascript": "javascriptreact"
},
"emmet.triggerExpansionOnTab": true,
"editor.codeActionsOnSave": {
//eslint-runs-automatically-on-save
"source.fixAll.eslint": true
},
"eslint.validate": [
@pratikdevdas
pratikdevdas / .eslintignore
Last active June 27, 2022 18:25
eslint(only) for nodejs
node_modules
build
@pratikdevdas
pratikdevdas / distanceformula.js
Created July 26, 2022 08:32
Mathematics with js
let x1, y1, x2, y2, result;
x1 = prompt('x1');
y1 = prompt('y1');
x2 = prompt('x2');
y2 = prompt('y2');
result = Math.sqrt(Math.pow((x2 - x1),2)+Math.pow((y2 - y1),2));
console.log(result.toFixed(4))