Skip to content

Instantly share code, notes, and snippets.

View ravid7000's full-sized avatar
🎯
Focusing

Ravi Dhiman ravid7000

🎯
Focusing
View GitHub Profile
import React from 'react';
import './App.css';
import { useTodoController } from './App.controller';
const App = () => {
const { state, actions } = useTodoController();
return (
<div className="container">
import { useMemo, useState } from "react"
export const useTodoController = () => {
const [todoList, setTodoList] = useState([]);
const [todoName, setTodoName] = useState('');
const [doneTodo, undoneTodo] = useMemo(() => {
const done = todoList.filter(item => item.done).length;
const undone = todoList.length - done;
import React, { useState } from 'react';
import './App.css';
const App = () => {
const [todoList, setTodoList] = useState([]);
const [todoName, setTodoName] = useState('');
const addTodo = (e) => {
e.preventDefault();
import { useCallback, useState, useEffect } from 'react';
function hasLocalStorageSupport() {
try {
if (typeof window === 'undefined') {
return false;
}
if (typeof localStorage === 'undefined' || typeof sessionStorage === 'undefined') {
return false;
}
function hasLocalStorageSupport() {
try {
if (typeof window === 'undefined') {
return false;
}
if (typeof localStorage === 'undefined' || typeof sessionStorage === 'undefined') {
return false;
}
} catch(e) {
return false;
@ravid7000
ravid7000 / javascript-typescript.code-snippets
Last active February 16, 2021 09:36
VSCode Javascript Typescript React Material-ui snippets
{
"Normal function": {
"scope": "javascript,typescript,javascriptreact,typescriptreact",
"prefix": "fn",
"body": [
"function $1($2) {",
" $3",
"}",
""
],
@ravid7000
ravid7000 / Uninstall VSCode.sh
Created January 20, 2021 06:23
Run following commands to uninstall vscode completely
# Run following commands to uninstall vscode completely
rm -fr ~/Library/Preferences/com.microsoft.VSCode.helper.plist
rm -fr ~/Library/Preferences/com.microsoft.VSCode.plist
rm -fr ~/Library/Caches/com.microsoft.VSCode
rm -fr ~/Library/Caches/com.microsoft.VSCode.ShipIt/
rm -fr ~/Library/Application\ Support/Code/
rm -fr ~/Library/Saved\ Application\ State/com.microsoft.VSCode.savedState/
rm -fr ~/.vscode/
<script>
s3UploadUtility({
fileInputElement: '#fileinputfield',
onFinished: function(paths) {
console.log(paths)
}
})
</script>
@ravid7000
ravid7000 / styled-baseButton.js
Created September 18, 2020 02:23
Button component using base element
import BaseElement from './baseElement';
export const BaseButton = styled(BaseElement).attrs(props => {
return {
as: 'button',
spacing: {
px: props.theme.spacing(2),
py: props.theme.spacing(1),
},
textAlign: 'center',
@ravid7000
ravid7000 / BaseElement.jsx
Last active September 18, 2020 02:30
styled component base element
import styled from 'styled-components';
/*
BaseElementProps {
// text alignment
textAlign?: 'left' | 'right' | 'center';
// spacing
ml?: string;