interface WithLoadingProps {
loading: boolean;
}
const withMaybe = <P extends object>(predicate: (props: P) => boolean) =>
(Component: React.ComponentType<P>) =>
(props: P) => predicate(props) ? <Component {...props}/> : null;
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
const url = 'https://www.lego.com/ko-kr/product/horizon-forbidden-west-tallneck-76989'; | |
const stockSelector = "#main-content > div > div.ProductDetailsPagestyles__ProductOverviewContainer-sc-1waehzg-1.dgDnXa > div > div.ProductOverviewstyles__Container-sc-1a1az6h-2.hHubKC > div.ProductOverviewstyles__PriceAvailabilityWrapper-sc-1a1az6h-10.bwcpjP > p > span"; | |
const titleSelector = "#main-content > div > div.ProductDetailsPagestyles__ProductOverviewContainer-sc-1waehzg-1.dgDnXa > div > div.ProductOverviewstyles__Container-sc-1a1az6h-2.hHubKC > div.ProductOverviewstyles__ProductOverviewRow-sc-1a1az6h-1.hblOYO > h1 > span"; | |
async function loadWeb(url, selectors) { | |
const wv = new WebView(); | |
wv.loadURL(url); | |
await wv.waitForLoad(); | |
return await wv.evaluateJavaScript(` |
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
Key.on("left", ["ctrl", "alt", "cmd"], function () { | |
const window = Window.focused(); | |
if (window) { | |
const currentFocusedScreen = window.screen(); | |
const screen = currentFocusedScreen.flippedVisibleFrame(); | |
// const screen = currentFocusedScreen.next().flippedVisibleFrame(); | |
if (isCloseRect(window.frame(), {x: screen.x, y: screen.y, width: screen.width / 2, height: screen.height})) { | |
if (closeTo(window.frame().width, screen.width / 2)) { | |
window.setFrame({ |
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
const url = encodeURI("https://m.search.daum.net/kakao?w=tot&DA=Z8T&rtmaxcoll=Z8T&q=서울 오늘 날씨") | |
const wv = new WebView() | |
wv.loadURL(url) | |
await wv.waitForLoad() | |
const cont = await wv.evaluateJavaScript(`[...document.querySelectorAll(".cont_air>ul>li")].map(t => { | |
return { | |
title: t.querySelector('.txt_type')?.innerText, |
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, {FC} from "react"; | |
const SimpleLineChart: FC<{ | |
width: number; | |
height: number; | |
strokeWidth?: number; | |
strokeColor?: string; | |
data: { value: number; label?: string }[]; | |
padding?: number; | |
}> = ({ |
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
const DonutChart: FC<{ | |
size: number; | |
data: { | |
value: number; | |
color: string; | |
}[]; | |
strokeWidth?: number; | |
bgColor?: string; | |
}> = ({size, strokeWidth = 10, bgColor, data}) => { | |
const cx = size / 2; |
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
// 수정 내용: 페이지 대신 ajax 호출로 속도 향상, 데이터 사용량 감소 | |
// 기본 색상 검은 배경, 흰 글씨, 빨간 아이콘으로 변경 | |
const source = 'http://corona-live.com'; | |
const request = new Request('https://apiv2.corona-live.com/stats.json?timestamp='+Date.now()) | |
const response = await request.loadJSON() | |
const count = response.overview.current[0]; | |
const now = new Date(); | |
const date = `${now.getMonth()+1}월 ${now.getDate()}일 ${now.toLocaleString('kr', { hour: 'numeric', minute: 'numeric', hour12: true })}`; |
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
// code from typescript/lib/lib.dom.d.ts | |
// It is useful when using react-native with typescript. | |
// Or you can add dom libarary as `lib: ["esnext" ,"dom"]` in tsconfig.json | |
interface WebSocketEventMap { | |
"close": CloseEvent; | |
"error": Event; | |
"message": MessageEvent; | |
"open": Event; | |
} |
수치 미분 Numerical Differentitaion link
f(x) = ax^n f`(x) = anx^(n-1) = df/dx (x) // 구조적으로 미분하는 해석적 방법
하지만 컴터엔 무한소가 없기때문에 수치 미분을 함
df/dx (x) = ( f(x + dx) - f(x) ) / dx // forward differentiation
NewerOlder