This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// All valid credit card numbers | |
const valid1 = [4, 5, 3, 9, 6, 7, 7, 9, 0, 8, 0, 1, 6, 8, 0, 8] | |
const valid2 = [5, 5, 3, 5, 7, 6, 6, 7, 6, 8, 7, 5, 1, 4, 3, 9] | |
const valid3 = [3, 7, 1, 6, 1, 2, 0, 1, 9, 9, 8, 5, 2, 3, 6] | |
const valid4 = [6, 0, 1, 1, 1, 4, 4, 3, 4, 0, 6, 8, 2, 9, 0, 5] | |
const valid5 = [4, 5, 3, 9, 4, 0, 4, 9, 6, 7, 8, 6, 9, 6, 6, 6] | |
const valid6 = [4, 5, 3, 9, 6, 8, 9, 8, 8, 7, 7, 0, 5, 7, 9, 8] | |
// All invalid credit card numbers | |
const invalid1 = [4, 5, 3, 2, 7, 7, 8, 7, 7, 1, 0, 9, 1, 7, 9, 5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
const Child = ({ resize, resizeParenObj }) => { | |
const { setResizeParent, resizeBox: resizeParent } = resizeParenObj; | |
return ( | |
<div | |
style={{ | |
width: `${resize}px`, | |
height: `${resize}px`, | |
margin: 10, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, memo, useMemo, useCallback } from "react"; | |
function Box({ color, onClick }) { | |
console.log(`Box color : ${color.color}`); | |
return ( | |
<div | |
style={{ | |
margin: 10, | |
width: 75, | |
height: 75, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { memo, useState } from 'react'; | |
export default function MyApp() { | |
const [name, setName] = useState(''); | |
const [address, setAddress] = useState(''); | |
return ( | |
<> | |
<label> | |
Name{': '} | |
<input value={name} onChange={e => setName(e.target.value)} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
glossary = { | |
"fruits": ["Apple", "Orange", "Banana"], | |
"vegetables": ["Cucumber", "Lemon", "Tomato"], | |
"sweets": ["Mars", "Kitkat", "Galaxy"] | |
} | |
# This about invers dictionary values from list to become a keys and their keys became a values that refer to them | |
def invert_dict(d): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_execution(func): | |
def wrapper(*args,**kwargs): | |
""" | |
This wrapper will use time module to check | |
the diffrence between the time when the excution start | |
and when it's end. | |
""" | |
import time | |
start = time.time() | |
value = func(*args,**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def check_type(current_type:object): | |
""" | |
This Decorator will check the datatype of the | |
target function to validate the datatype arguments. | |
""" | |
def get_func(func): | |
def wrapper(*args,**kwargs): | |
check_values = [] | |
bad_values = [] | |
if args: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def in_range(number:int, range_from:int, range_to:int) -> bool: | |
return number in list(range(range_from,range_to+1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def alarm_me(minutes: int, message:str) -> str: | |
alarm_time = time.time() + minutes * 60 | |
while True: | |
if time.time() > alarm_time: | |
break | |
print(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
class EmailChecker: | |
def __init__(self,email:str): | |
self.email = email | |
self.id = None | |
self.provider= None | |
self.extention =None | |
self.is_valid() | |
def is_valid(self): |
NewerOlder