This file contains hidden or 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
let result_get = await axios.get(url, {params:params, headers:{Authorization:token}}) | |
let result_post = await axios.post(url, params, {headers:{Authorization:token}}); |
This file contains hidden or 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 {useState, useEffect} from 'react' | |
export const useCountdown = (startFrom:number, startCountDown:boolean=false, timeoutFunction:any, stopCountingDown:boolean=false) =>{ | |
/* | |
startFrom: number that the countdown starts from. | |
startCountDown: turnning this from false to true triggers countdown. | |
timeoutFunction: a function that will be triggered when countdown reaches 0 | |
stopCountingDown: if it turns true, countdown stops | |
*/ | |
const [counter, handleCounter] = useState(startFrom); | |
useEffect(()=>{ |
This file contains hidden or 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
const AWS = require('aws-sdk'); | |
AWS.config.update({region: 'us-east-1'}); //Set Region | |
exports.handler = (event) => { | |
return new Promise((res, rej)=>{ | |
const sns = new AWS.SNS(); | |
console.log('event', event); | |
let {phonenumber, message, requestContext} = JSON.parse(event.body); | |
let {http} = event.requestContext; | |
if(http.method ==='POST'){ |
This file contains hidden or 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 { useEffect, useState } from 'react'; | |
type SubKey = 'Control'|'Alt'|'Tab'|'Shift'|'NN'; | |
type NodeEnv = 'production'|'development'|'test' | |
const useKeydown = (nodeEnv:NodeEnv):{subKey:SubKey, mainKey:string} => { | |
const [subKey, handleSubKey] = useState<'Control'|'Alt'|'Tab'|'Shift'|'NN'>('NN') | |
const [mainKey, handleMainKey] = useState<string>('') | |
useEffect(() => { | |
window.addEventListener('keydown', handleKeydown); | |
return () => removeEventListener('keydown', handleKeydown) | |
}, []); |
This file contains hidden or 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
const KeyDown = () => { | |
useEffect(() => { | |
window.addEventListener('keydown', handleKeydown); | |
return () => removeEventListener('keydown', handleKeydown) | |
}, []); | |
const doSomething1 = () => { | |
console.log('doSomething1'); | |
} | |
This file contains hidden or 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
{ | |
"body" : $input.json('$'), | |
"headers": { | |
#foreach($header in $input.params().header.keySet()) | |
"$header": "$util.escapeJavaScript($input.params().header.get($header))" #if($foreach.hasNext),#end | |
#end | |
}, | |
"method": "$context.httpMethod", | |
"params": { |
This file contains hidden or 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 {useEffect, useState} from 'react'; | |
import {useCamera} from '@tofusoup429/camera'; | |
import { useWindowSize } from '@tofusoup429/use-window-size'; | |
import LensSharpIcon from '@material-ui/icons/LensSharp'; | |
import LoopIcon from '@material-ui/icons/Loop'; | |
const FullScreenMobileView = () => { | |
let {width, height} = useWindowSize() // get window width and height as everytime screen resized. | |
const {captureImage ,imageData, switchCameraFacingMode} = useCamera(); // customHook that contains logics | |
const [imageDatas, handleImageDatas] = useState<string[]>([]) // capture imageUrls are saved in this state. | |
This file contains hidden or 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 {useEffect, useState} from 'react'; | |
type CameraFacingMode = "environment"|"user" | |
export const useCamera = ()=> { | |
const [videoDem, handleVideoDem] = useState<{w:number, h:number}>({w:0, h:0}) | |
const [cameraFacingMode, handleCameraFacingMode] = useState<CameraFacingMode>('environment') | |
const [imageData, handleImageData] = useState(''); | |
let video:HTMLVideoElement; | |
let canvas:HTMLCanvasElement; |
This file contains hidden or 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
const months = ["Jan", "Mar", "Mar", "April"]; | |
let febs = ["Feb", "Feb2", "Feb4"]; | |
let returnedValue = months.splice(1, 3, ...febs); | |
console.log(returnedValue) | |
//output: ["Mar","Mar","April"] |
NewerOlder